From f4e87355479be39cf7715b33c415ec7da2a98ac9 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Wed, 27 Feb 2013 17:17:37 +0200 Subject: [PATCH] clean up the canvas hovering code --- src/layer/vector/canvas/Path.Canvas.js | 33 +++++++------------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/src/layer/vector/canvas/Path.Canvas.js b/src/layer/vector/canvas/Path.Canvas.js index 271c5c18..0f9ef739 100644 --- a/src/layer/vector/canvas/Path.Canvas.js +++ b/src/layer/vector/canvas/Path.Canvas.js @@ -131,38 +131,23 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : _onClick: function (e) { if (this._containsPoint(e.layerPoint)) { - this.fire('click', { - latlng: e.latlng, - layerPoint: e.layerPoint, - containerPoint: e.containerPoint, - originalEvent: e - }); + this.fire('click', e); } }, _onMouseMove: function (e) { if (this._map._animatingZoom) { return; } + // TODO don't do on each move if (this._containsPoint(e.layerPoint)) { this._ctx.canvas.style.cursor = 'pointer'; - this.currentlyOver = true; - this.fire('mouseover', { - latlng: e.latlng, - layerPoint: e.layerPoint, - containerPoint: e.containerPoint, - originalEvent: 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 - }); - } + this._mouseInside = true; + this.fire('mouseover', e); + + } else if (this._mouseInside) { + this._ctx.canvas.style.cursor = ''; + this._mouseInside = false; + this.fire('mouseout', e); } } });