Merge pull request #3582 from wpf500/wpf-mouse-event-order
Fix ordering of mouse events in Canvas renderer
This commit is contained in:
commit
ae90893e1e
@ -200,17 +200,29 @@ L.Canvas = L.Renderer.extend({
|
|||||||
if (!this._map || this._map._animatingZoom) { return; }
|
if (!this._map || this._map._animatingZoom) { return; }
|
||||||
|
|
||||||
var point = this._map.mouseEventToLayerPoint(e);
|
var point = this._map.mouseEventToLayerPoint(e);
|
||||||
|
var id;
|
||||||
|
|
||||||
// TODO don't do on each move event, throttle since it's expensive
|
// TODO don't do on each move event, throttle since it's expensive
|
||||||
for (var id in this._layers) {
|
for (id in this._layers) {
|
||||||
this._handleHover(this._layers[id], e, point);
|
this._handleMouseOut(this._layers[id], e, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (id in this._layers) {
|
||||||
|
this._handleMouseHover(this._layers[id], e, point);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleHover: function (layer, e, point) {
|
_handleMouseOut: function (layer, e, point) {
|
||||||
if (!layer.options.interactive) { return; }
|
if (layer.options.interactive && layer._mouseInside && !layer._containsPoint(point)) {
|
||||||
|
// if we're leaving the layer, fire mouseout
|
||||||
|
L.DomUtil.removeClass(this._container, 'leaflet-interactive');
|
||||||
|
this._fireEvent(layer, e, 'mouseout');
|
||||||
|
layer._mouseInside = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
if (layer._containsPoint(point)) {
|
_handleMouseHover: function (layer, e, point) {
|
||||||
|
if (layer.options.interactive && layer._containsPoint(point)) {
|
||||||
// if we just got inside the layer, fire mouseover
|
// if we just got inside the layer, fire mouseover
|
||||||
if (!layer._mouseInside) {
|
if (!layer._mouseInside) {
|
||||||
L.DomUtil.addClass(this._container, 'leaflet-interactive'); // change cursor
|
L.DomUtil.addClass(this._container, 'leaflet-interactive'); // change cursor
|
||||||
@ -219,12 +231,6 @@ L.Canvas = L.Renderer.extend({
|
|||||||
}
|
}
|
||||||
// fire mousemove
|
// fire mousemove
|
||||||
this._fireEvent(layer, e);
|
this._fireEvent(layer, e);
|
||||||
|
|
||||||
} else if (layer._mouseInside) {
|
|
||||||
// if we're leaving the layer, fire mouseout
|
|
||||||
L.DomUtil.removeClass(this._container, 'leaflet-interactive');
|
|
||||||
this._fireEvent(layer, e, 'mouseout');
|
|
||||||
layer._mouseInside = false;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user