Commit ce12faee authored by Jason Davies's avatar Jason Davies
Browse files

Ensure that touch{move,end} listeners are removed.

Previously, if there were globally-active touches remaining, a given
zoom gesture was not ended even if locations0 was empty.  This fixes the
problem by checking to see if locations0 is empty.  If so, the gesture
is ended.
parent 85e738ea
......@@ -1412,13 +1412,14 @@ d3 = function() {
for (var i = 0, n = changed.length; i < n; ++i) {
delete locations0[changed[i].identifier];
}
relocate();
} else {
w.on(touchmove, null).on(touchend, null);
t.on(mousedown, mousedowned).on(touchstart, touchstarted);
dragRestore();
zoomended(event_);
for (var identifier in locations0) {
return relocate();
}
}
w.on(touchmove, null).on(touchend, null);
t.on(mousedown, mousedowned).on(touchstart, touchstarted);
dragRestore();
zoomended(event_);
}
}
function mousewheeled() {
......
This diff is collapsed.
......@@ -261,18 +261,24 @@ d3.behavior.zoom = function() {
}
function ended() {
// If there are any globally-active touches remaining, remove the ended
// touches from locations0.
if (d3.event.touches.length) {
var changed = d3.event.changedTouches;
for (var i = 0, n = changed.length; i < n; ++i) {
delete locations0[changed[i].identifier];
}
relocate(); // locations may have detached due to rotation
} else {
w.on(touchmove, null).on(touchend, null);
t.on(mousedown, mousedowned).on(touchstart, touchstarted);
dragRestore();
zoomended(event_);
// If locations0 is not empty, then relocate and continue listening for
// touchmove and touchend.
for (var identifier in locations0) {
return relocate(); // locations may have detached due to rotation
}
}
// Otherwise, remove touchmove and touchend listeners.
w.on(touchmove, null).on(touchend, null);
t.on(mousedown, mousedowned).on(touchstart, touchstarted);
dragRestore();
zoomended(event_);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment