Skip to content

Commit

Permalink
Replicated pull request fix for touch events
Browse files Browse the repository at this point in the history
  • Loading branch information
Pkmmte committed Apr 28, 2021
1 parent 72a7660 commit ec86e8a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/DraggableCore.js
Expand Up @@ -242,6 +242,7 @@ export default class DraggableCore extends React.Component<DraggableCoreProps, D
// https://developers.google.com/web/updates/2017/01/scrolling-intervention
const thisNode = this.findDOMNode();
if (thisNode) {
addEvent(thisNode, eventsFor.mouse.start, this.onMouseDown, {passive: false});
addEvent(thisNode, eventsFor.touch.start, this.onTouchStart, {passive: false});
}
}
Expand All @@ -257,6 +258,7 @@ export default class DraggableCore extends React.Component<DraggableCoreProps, D
removeEvent(ownerDocument, eventsFor.touch.move, this.handleDrag);
removeEvent(ownerDocument, eventsFor.mouse.stop, this.handleDragStop);
removeEvent(ownerDocument, eventsFor.touch.stop, this.handleDragStop);
removeEvent(thisNode, eventsFor.mouse.start, this.onMouseDown, {passive: false});
removeEvent(thisNode, eventsFor.touch.start, this.onTouchStart, {passive: false});
if (this.props.enableUserSelectHack) removeUserSelectStyles(ownerDocument);
}
Expand Down Expand Up @@ -446,7 +448,7 @@ export default class DraggableCore extends React.Component<DraggableCoreProps, D
return React.cloneElement(React.Children.only(this.props.children), {
// Note: mouseMove handler is attached to document so it will still function
// when the user drags quickly and leaves the bounds of the element.
onMouseDown: this.onMouseDown,
// onMouseDown is added on `componentDidMount` so the click can be cancelled
onMouseUp: this.onMouseUp,
// onTouchStart is added on `componentDidMount` so they can be added with
// {passive: false}, which allows it to cancel. See
Expand Down

0 comments on commit ec86e8a

Please sign in to comment.