Skip to content

Commit

Permalink
Include source event information in some feature events.
Browse files Browse the repository at this point in the history
This, for instance, allows a event.feature.mouseclick to mark that the
underlying event.mouseclick has been processed.
  • Loading branch information
manthey committed Jul 5, 2019
1 parent 252a594 commit 0b260f1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
14 changes: 11 additions & 3 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ geo_event.feature = {
* features that the mouse moves over simultaneously will have the same
* `eventID`.
* @property {boolean} top True if this is the topmost data element.
* @property {geo.event} sourceEvent The underlying event that trigger this.
*/
mousemove: 'geo_feature_mousemove',
/**
Expand All @@ -365,6 +366,7 @@ geo_event.feature = {
* features that the mouse goes over simultaneously will have the same
* `eventID`.
* @property {boolean} top True if this is the topmost data element.
* @property {geo.event} sourceEvent The underlying event that trigger this.
*/
mouseover: 'geo_feature_mouseover',
/**
Expand All @@ -375,10 +377,11 @@ geo_event.feature = {
* @type {geo.event.base}
* @property {geo.feature} feature The feature.
* @property {geo.mouseState} mouse The mouse state.
* @proeprty {geo.feature.searchResult} over A list of feature components
* @property {geo.feature.searchResult} over A list of feature components
* that the mouse is over.
* @proeprty {number[]} The indices of the data components that the mouse
* @property {number[]} The indices of the data components that the mouse
* was over before this event.
* @property {geo.event} sourceEvent The underlying event that trigger this.
*/
mouseover_order: 'geo_feature_mouseover_order',
/**
Expand All @@ -397,6 +400,7 @@ geo_event.feature = {
* features that the mouse goes over simultaneously will have the same
* `eventID`.
* @property {boolean} top True if this is the topmost data element.
* @property {geo.event} sourceEvent The underlying event that trigger this.
*/
mouseout: 'geo_feature_mouseout',
/**
Expand All @@ -408,6 +412,7 @@ geo_event.feature = {
* @property {object} data The feature data the mouse is on.
* @property {number} index The index of the feature data the mouse is on.
* @property {geo.mouseState} mouse The mouse state.
* @property {geo.event} sourceEvent The underlying event that trigger this.
*/
mouseon: 'geo_feature_mouseon',
/**
Expand All @@ -419,6 +424,7 @@ geo_event.feature = {
* @property {object} data The feature data the mouse is off.
* @property {number} index The index of the feature data the mouse is off.
* @property {geo.mouseState} mouse The mouse state.
* @property {geo.event} sourceEvent The underlying event that trigger this.
*/
mouseoff: 'geo_feature_mouseoff',
/**
Expand All @@ -435,6 +441,7 @@ geo_event.feature = {
* features that the mouse clicks simultaneously will have the same
* `eventID`.
* @property {boolean} top True if this is the topmost data element.
* @property {geo.event} sourceEvent The underlying event that trigger this.
*/
mouseclick: 'geo_feature_mouseclick',
/**
Expand All @@ -445,8 +452,9 @@ geo_event.feature = {
* @type {geo.event.base}
* @property {geo.feature} feature The feature that was clicked.
* @property {geo.mouseState} mouse The mouse state.
* @proeprty {geo.feature.searchResult} over A list of feature components
* @property {geo.feature.searchResult} over A list of feature components
* that the mouse is over.
* @property {geo.event} sourceEvent The underlying event that trigger this.
*/
mouseclick_order: 'geo_feature_mouseclick_order',
/**
Expand Down
27 changes: 18 additions & 9 deletions src/feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,15 @@ var feature = function (arg) {
* Private mousemove handler. This uses `pointSearch` to determine which
* features the mouse is over, then fires appropriate events.
*
* @param {geo.event} evt The event that triggered this handler.
* @fires geo.event.feature.mouseover_order
* @fires geo.event.feature.mouseover
* @fires geo.event.feature.mouseout
* @fires geo.event.feature.mousemove
* @fires geo.event.feature.mouseoff
* @fires geo.event.feature.mouseon
*/
this._handleMousemove = function () {
this._handleMousemove = function (evt) {
var mouse = m_this.layer().map().interactor().mouse(),
data = m_this.data(),
over = m_this.pointSearch(mouse.geo),
Expand All @@ -241,7 +242,8 @@ var feature = function (arg) {
feature: m_this,
mouse: mouse,
previous: m_selectedFeatures,
over: over
over: over,
sourceEvent: evt
});
}

Expand All @@ -267,7 +269,8 @@ var feature = function (arg) {
extra: extra[i],
mouse: mouse,
eventID: feature.eventID,
top: idx === newFeatures.length - 1
top: idx === newFeatures.length - 1,
sourceEvent: evt
}, true);
});

Expand All @@ -279,7 +282,8 @@ var feature = function (arg) {
index: i,
mouse: mouse,
eventID: feature.eventID,
top: idx === oldFeatures.length - 1
top: idx === oldFeatures.length - 1,
sourceEvent: evt
}, true);
});

Expand All @@ -292,7 +296,8 @@ var feature = function (arg) {
extra: extra[i],
mouse: mouse,
eventID: feature.eventID,
top: idx === over.index.length - 1
top: idx === over.index.length - 1,
sourceEvent: evt
}, true);
});

Expand All @@ -310,7 +315,8 @@ var feature = function (arg) {
m_this.geoTrigger(geo_event.feature.mouseoff, {
data: data[lastTop],
index: lastTop,
mouse: mouse
mouse: mouse,
sourceEvent: evt
}, true);
}

Expand All @@ -319,7 +325,8 @@ var feature = function (arg) {
data: data[top],
index: top,
extra: extra[top],
mouse: mouse
mouse: mouse,
sourceEvent: evt
}, true);
}
}
Expand Down Expand Up @@ -357,7 +364,8 @@ var feature = function (arg) {
m_this.geoTrigger(geo_event.feature.mouseclick_order, {
feature: m_this,
mouse: mouse,
over: over
over: over,
sourceEvent: evt
});
}
mouse.buttonsDown = evt.buttonsDown;
Expand All @@ -369,7 +377,8 @@ var feature = function (arg) {
extra: extra[i],
mouse: mouse,
eventID: feature.eventID,
top: idx === over.index.length - 1
top: idx === over.index.length - 1,
sourceEvent: evt
}, true);
});
};
Expand Down

0 comments on commit 0b260f1

Please sign in to comment.