From 6d12053b5b1cb0f2dd884847c5d2ba5a82a21db9 Mon Sep 17 00:00:00 2001 From: danzel Date: Wed, 18 Dec 2013 10:16:14 +1300 Subject: [PATCH] Prevent multiple clustermouseover/off events if the icon is made up of stacked divs. Fixes #252. Doesn't fix this bug in IE <= 8 as they don't support relatedTarget, could fix it by looking at the event type and using fromElement/toElement, but I'm not going to. --- src/MarkerClusterGroup.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 313d8e29a..476b8e032 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -547,8 +547,22 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ delete marker.__parent; }, + _isOrIsParent: function (el, oel) { + while (oel) { + if (el === oel) { + return true; + } + oel = oel.parentNode; + } + return false; + }, + _propagateEvent: function (e) { if (e.layer instanceof L.MarkerCluster) { + //Prevent multiple clustermouseover/off events if the icon is made up of stacked divs (Doesn't work in ie <= 8, no relatedTarget) + if (this._isOrIsParent(e.layer._icon, e.originalEvent.relatedTarget)) { + return; + } e.type = 'cluster' + e.type; }