From 7254719ac6b4e6ca0b22a5c41516b081c8fddcc8 Mon Sep 17 00:00:00 2001 From: danzel Date: Tue, 7 Aug 2012 11:31:39 +1200 Subject: [PATCH] Fix #27 for touch zoom --- src/MarkerCluster.Spiderfier.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/MarkerCluster.Spiderfier.js b/src/MarkerCluster.Spiderfier.js index be6f6af9c..21209d063 100644 --- a/src/MarkerCluster.Spiderfier.js +++ b/src/MarkerCluster.Spiderfier.js @@ -309,10 +309,11 @@ L.MarkerClusterGroup.include({ this._map.on('click', this._unspiderfyWrapper, this); this._map.on('zoomstart', this._unspiderfyZoomStart, this); - if (L.Browser.svg) { - this._map._initPathRoot(); //Needs to happen in the pageload, not after, or animations don't work in chrome + if (L.Browser.svg && !L.Browser.touch) { + this._map._initPathRoot(); + //Needs to happen in the pageload, not after, or animations don't work in webkit // http://stackoverflow.com/questions/8455200/svg-animate-with-dynamically-added-elements - + //Disable on touch browsers as the animation messes up on a touch zoom and isn't very noticable } }, @@ -328,6 +329,11 @@ L.MarkerClusterGroup.include({ this._map.on('zoomanim', this._unspiderfyZoomAnim, this); }, _unspiderfyZoomAnim: function (zoomDetails) { + //Wait until the first zoomanim after the user has finished touch-zooming before running the animation + if (L.DomUtil.hasClass(this._map._mapPane, 'leaflet-touching')) { + return; + } + this._map.off('zoomanim', this._unspiderfyZoomAnim, this); this._unspiderfy(zoomDetails); },