Skip to content

Commit c36dbcd

Browse files
committed
only cancel touch events if it was the right touch
1 parent fe5faf2 commit c36dbcd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/draggable.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ module.exports = React.createClass({
516516
handleDragStart: function (e) {
517517
// Set touch identifier in component state if this is a touch event
518518
if(e.targetTouches){
519-
this.setState({identifier: e.targetTouches[0].identifier});
519+
this.setState({touchIdentifier: e.targetTouches[0].identifier});
520520
}
521521

522522
// Make it possible to attach event handlers on top of this one
@@ -562,6 +562,11 @@ module.exports = React.createClass({
562562
return;
563563
}
564564

565+
// Short circuit if this is not the correct touch event
566+
if(e.changedTouches && (e.changedTouches[0].identifier != this.state.touchIdentifier)){
567+
return;
568+
}
569+
565570
removeUserSelectStyles(this);
566571

567572
// Turn off dragging
@@ -580,7 +585,7 @@ module.exports = React.createClass({
580585

581586
handleDrag: function (e) {
582587
// Return if this is a touch event, but not the correct one for this element
583-
if(e.targetTouches && (e.targetTouches[0].identifier != this.state.identifier)){
588+
if(e.targetTouches && (e.targetTouches[0].identifier != this.state.touchIdentifier)){
584589
return;
585590
}
586591
var dragPoint = getControlPosition(e);

0 commit comments

Comments
 (0)