From baeeddb078547c6e3d6a0ab97426dfba53f8ad55 Mon Sep 17 00:00:00 2001 From: snkashis Date: Sun, 17 Feb 2013 14:17:44 -0500 Subject: [PATCH] Hand cursor for canvas paths --- debug/tests/click_on_canvas.html | 14 +++++++++++--- src/layer/vector/canvas/Path.Canvas.js | 18 ++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/debug/tests/click_on_canvas.html b/debug/tests/click_on_canvas.html index 2209748e..552b4adc 100644 --- a/debug/tests/click_on_canvas.html +++ b/debug/tests/click_on_canvas.html @@ -14,11 +14,16 @@ + + diff --git a/src/layer/vector/canvas/Path.Canvas.js b/src/layer/vector/canvas/Path.Canvas.js index f184cf0d..4a1cba8e 100644 --- a/src/layer/vector/canvas/Path.Canvas.js +++ b/src/layer/vector/canvas/Path.Canvas.js @@ -123,8 +123,8 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : _initEvents: function () { if (this.options.clickable) { - // TODO hand cursor - // TODO mouseover, mouseout, dblclick + // TODO mouseout, dblclick + this._map.on('mousemove', this._onMouseMove, this); this._map.on('click', this._onClick, this); } }, @@ -138,6 +138,20 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : originalEvent: e }); } + }, + + _onMouseMove: function (e) { + if (this._containsPoint(e.layerPoint)) { + this._ctx.canvas.style.cursor = 'pointer'; + this.fire('mouseover', { + latlng: e.latlng, + layerPoint: e.layerPoint, + containerPoint: e.containerPoint, + originalEvent: e + }); + } else { + this._ctx.canvas.style.cursor = ''; + } } });