Skip to content

Commit c16417c

Browse files
committed
Better handling of "touchend".
We can't check for existence of event.touches to decide whether to use it or not for touchend, as it always exists, just not containing the touch that just ended.
1 parent d0d665c commit c16417c

3 files changed

Lines changed: 8 additions & 12 deletions

File tree

d3.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3872,7 +3872,7 @@ function d3_behavior_dragDispatch(type) {
38723872
var o = d3.event, p = d3_behavior_dragTarget.parentNode, dx = 0, dy = 0;
38733873

38743874
if (p) {
3875-
p = d3_behavior_dragPoint(p);
3875+
p = d3_behavior_dragPoint(p, type);
38763876
dx = p[0] - d3_behavior_dragOffset[0];
38773877
dy = p[1] - d3_behavior_dragOffset[1];
38783878
d3_behavior_dragOffset = p;
@@ -3889,12 +3889,10 @@ function d3_behavior_dragDispatch(type) {
38893889
o.preventDefault();
38903890
}
38913891

3892-
function d3_behavior_dragPoint(container) {
3892+
function d3_behavior_dragPoint(container, type) {
38933893
// TODO Track touch points by identifier.
38943894
return d3.event.touches
3895-
? d3.svg.touches(container)[0]
3896-
: d3.event.changedTouches
3897-
? d3.svg.touches(container, d3.event.changedTouches)[0]
3895+
? d3.svg.touches(container, d3.event[type === "touchend" ? "changedTouches" : "touches"])[0]
38983896
: d3.svg.mouse(container);
38993897
}
39003898

0 commit comments

Comments
 (0)