From 6a8c0ed159f4a10bbc49138815273dc1202bf9c8 Mon Sep 17 00:00:00 2001 From: Buggytheclown Date: Mon, 23 Jan 2017 13:51:55 +0300 Subject: [PATCH] Fix mobile touch to zoom. Only perform fast click. --- src/markerclusterer.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/markerclusterer.js b/src/markerclusterer.js index 554fcec..e7efcf4 100755 --- a/src/markerclusterer.js +++ b/src/markerclusterer.js @@ -1075,18 +1075,18 @@ ClusterIcon.prototype.onAdd = function() { panes.overlayMouseTarget.appendChild(this.div_); var that = this; - var isDragging = false; + var inClickMs = 0; google.maps.event.addDomListener(this.div_, 'click', function(event) { - // Only perform click when not preceded by a drag - if (!isDragging) { + // Only perform fast click to zoom + if (inClickMs < 300) { that.triggerClusterClick(event); } }); google.maps.event.addDomListener(this.div_, 'mousedown', function() { - isDragging = false; + inClickMs = Date.now(); }); - google.maps.event.addDomListener(this.div_, 'mousemove', function() { - isDragging = true; + google.maps.event.addDomListener(this.div_, 'mouseup', function() { + inClickMs = Date.now() - inClickMs; }); };