clean up the canvas hovering code

This commit is contained in:
Vladimir Agafonkin 2013-02-27 17:17:37 +02:00
parent 1d4e91f9fa
commit f4e8735547

View File

@ -131,38 +131,23 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
_onClick: function (e) { _onClick: function (e) {
if (this._containsPoint(e.layerPoint)) { if (this._containsPoint(e.layerPoint)) {
this.fire('click', { this.fire('click', e);
latlng: e.latlng,
layerPoint: e.layerPoint,
containerPoint: e.containerPoint,
originalEvent: e
});
} }
}, },
_onMouseMove: function (e) { _onMouseMove: function (e) {
if (this._map._animatingZoom) { return; } if (this._map._animatingZoom) { return; }
// TODO don't do on each move
if (this._containsPoint(e.layerPoint)) { if (this._containsPoint(e.layerPoint)) {
this._ctx.canvas.style.cursor = 'pointer'; this._ctx.canvas.style.cursor = 'pointer';
this.currentlyOver = true; this._mouseInside = true;
this.fire('mouseover', { this.fire('mouseover', e);
latlng: e.latlng,
layerPoint: e.layerPoint, } else if (this._mouseInside) {
containerPoint: e.containerPoint, this._ctx.canvas.style.cursor = '';
originalEvent: e this._mouseInside = false;
}); this.fire('mouseout', e);
} else {
if (this.currentlyOver) {
this._ctx.canvas.style.cursor = '';
this.currentlyOver = false;
this.fire('mouseout', {
latlng: e.latlng,
layerPoint: e.layerPoint,
containerPoint: e.containerPoint,
originalEvent: e
});
}
} }
} }
}); });