react-grid-layout / react-draggable

React draggable component
MIT License
8.99k stars 1.03k forks source link

Safari for iDevices drags entire screen #279

Open scbrady opened 7 years ago

scbrady commented 7 years ago

When dragging in Safari on iDevices (I specifically tested an iPhone 7 and iPad Air 2, both running iOS 10.3) the entire screen scrolls with the drag. I tested it both on my website and on the react-draggable example page.

I see that in issue #165, this should have been taken care of, but it doesn't seem to be. Possibly Safari updated the way they handle dragging?

I'm going to keep looking for workarounds for this, but so far I haven't been able to find anything that works.

denis-sokolov commented 7 years ago

onStart={e => e.preventDefault()} fixed it for me on an iPad Air iOS 10.3.

demian85 commented 6 years ago

This is not working for me on iOS 11 😕 Any suggestions?

jasoniangreen commented 5 years ago

I fixed by putting this

handlePreventTouchmoveWhenPanning = (event: *) => {
 if (this.state.panning) {
   event.preventDefault();
 }
};

componentDidMount () {
 window.document.body.addEventListener(‘touchmove’, this.handlePreventTouchmoveWhenPanning, {
   passive: false
 });
}

componentWillUnmount () {
 window.document.body.removeEventListener(‘touchmove’, this.handlePreventTouchmoveWhenPanning, {
   passive: false
 });
}