Skip to content

Commit 69f02eb

Browse files
committed
Don't interpret double-pan as double-tap.
Firstly, the last-touched-time was being set on touchend, even if a pan gesture had occurred. This caused a pan quickly followed by a single tap to be interpreted as a double-tap. In this fix, the time is only set on touchstart. Secondly, the time is cleared on touchmove, so that a pan gesture cancels double-tap detection.
1 parent c5d230d commit 69f02eb

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

d3.v2.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4869,13 +4869,15 @@ d3.behavior.zoom = function() {
48694869
touches.forEach(function(t) { translate0[t.identifier] = location(t); });
48704870
d3_eventCancel();
48714871

4872-
if ((touches.length === 1) && (now - touchtime < 500)) { // dbltap
4873-
var p = touches[0], l = location(touches[0]);
4874-
scaleTo(scale * 2);
4875-
translateTo(p, l);
4876-
dispatch(event.of(this, arguments));
4872+
if (touches.length === 1) {
4873+
if (now - touchtime < 500) { // dbltap
4874+
var p = touches[0], l = location(touches[0]);
4875+
scaleTo(scale * 2);
4876+
translateTo(p, l);
4877+
dispatch(event.of(this, arguments));
4878+
}
4879+
touchtime = now;
48774880
}
4878-
touchtime = now;
48794881
}
48804882

48814883
function touchmove() {
@@ -4889,6 +4891,7 @@ d3.behavior.zoom = function() {
48894891
scaleTo(d3.event.scale * scale0);
48904892
}
48914893
translateTo(p0, l0);
4894+
touchtime = null;
48924895
dispatch(event.of(this, arguments));
48934896
}
48944897

0 commit comments

Comments
 (0)