dragula icon indicating copy to clipboard operation
dragula copied to clipboard

iOS10: can't drag anything without scrolling

Open jessicest opened this issue 8 years ago • 15 comments

On iOS10, when trying to drag a dragula item, it scrolls the page. This makes the drag and drop functionality unusable on iOS10.

Steps to reproduce:

  • use an iOS10 device. (the iOS Simulator can also reproduce this)
  • go to https://bevacqua.github.io/dragula/
  • try to drag any of the objects

expected: dragging an item should move it around the page. observe: while trying to drag, it scrolls the page, so the item doesn't move.

jessicest avatar Sep 26 '16 06:09 jessicest

+1

dweitz43 avatar Oct 03 '16 11:10 dweitz43

+1

scooterlord avatar Oct 05 '16 21:10 scooterlord

Any news? :(

saschanos avatar Oct 12 '16 16:10 saschanos

+1

gvlekke avatar Oct 17 '16 14:10 gvlekke

could try this... https://github.com/metafizzy/flickity/issues/457#issuecomment-254501356

dweitz43 avatar Oct 20 '16 13:10 dweitz43

Thanks @dweitz43.

window.addEventListener( 'touchmove', function() {})

Works like a champ

cweidinger avatar Nov 14 '16 19:11 cweidinger

Related: #413, #457

adam-lynch avatar Apr 14 '17 14:04 adam-lynch

touch-action: none; seems to fix every other browser (so it's fine on everything including iPad) but not iPhone.

adam-lynch avatar Apr 18 '17 08:04 adam-lynch

@cweidinger bless your soul!

pawel2105 avatar Jun 02 '17 08:06 pawel2105

Hey the solution window.addEventListener( 'touchmove', function() {}) dont work for me on iphone with ios 11. does anyone knows what am i doing wrong? Thanks

yosigolan avatar Apr 09 '18 10:04 yosigolan

Also noticing that the proposed fix does not seem to work on iOS 11 😢

edit: well, this is working for me

/**
 * Fixes issue where dragging will cause iOS safari to also scroll.
 *
 * @see https://github.com/bevacqua/dragula/issues/426
 * @return void
 */
function patchIosDragScroll() {
  window.addEventListener('touchmove', e => e.preventDefault(), { passive: false });
}

patchIosDragScroll();

edit2: welp, spoke too soon, this just stops scrolling from working at all. Sigh.

rohan-deshpande avatar Jul 28 '18 07:07 rohan-deshpande

Also noticing that the proposed fix does not seem to work on iOS 11 😢

edit: well, this is working for me

/**
 * Fixes issue where dragging will cause iOS safari to also scroll.
 *
 * @see https://github.com/bevacqua/dragula/issues/426
 * @return void
 */
function patchIosDragScroll() {
  window.addEventListener('touchmove', e => e.preventDefault(), { passive: false });
}

patchIosDragScroll();

edit2: welp, spoke too soon, this just stops scrolling from working at all. Sigh.

To expand upon this idea I got it working in Angular.

Set a dragging variable that is tracked and set by dragula.

dragging = true

 const _this = this;
 window.addEventListener('touchmove', function(e) {
     e.returnValue = true;
     if (_this.dragging) {
         e.preventDefault();
     }
},
    {
        passive: _this.dragging
    }
);

gspeach avatar Jul 09 '19 21:07 gspeach

Is there any good solution that works on any devices?

@gspeach do you have a working example? some bit of more code? Where / when shall i do this: "Set a dragging variable that is tracked and set by dragula." ?

Horst1102 avatar Oct 23 '19 13:10 Horst1102

I am using it like this:

dragging = false;

constructor(
         ...
    ) {
        document.addEventListener('touchmove', (e) => {
            if (this.dragging) {
                e.preventDefault();
            }
        }, {passive: false});
    }
ngOnInit() {
        this.dragulaService.createGroup('DRAGULA_CONTAINER', {});

        this.dragulaService.drag('DRAGULA_CONTAINER')
            .subscribe(({name, el, source}) => {
                console.log('drag');
                this.dragging = true;

            });

        this.dragulaService.dragend('DRAGULA_CONTAINER')
            .subscribe(({name, el}) => {
                console.log('dragend');
                this.dragging = false;
            });
    }

I want to use it togther with dom-autoscroller and it is working in chrome browser but not on IOSdevice. When i remove the eventListener the autoscroll is working on the iOS device but the page scrolls up/down when moving the elements.

Horst1102 avatar Oct 24 '19 06:10 Horst1102

Is this library maintained any more?

amk221 avatar Feb 29 '20 13:02 amk221