ng-sortable icon indicating copy to clipboard operation
ng-sortable copied to clipboard

Long Press option not working on mobile devices

Open prasannavalleti opened this issue 8 years ago • 5 comments

prasannavalleti avatar Dec 14 '16 07:12 prasannavalleti

@a5hik any updates on this ?

vTrip avatar Jan 11 '17 03:01 vTrip

I am also facing same issue. On long press of Item my screen is getting reloaded :-(

princexebia avatar Feb 02 '17 06:02 princexebia

longTouch attribute never gets applied.

mikey0000 avatar Nov 22 '17 21:11 mikey0000

going to use https://github.com/SortableJS/angular-legacy-sortablejs

mikey0000 avatar Nov 22 '17 22:11 mikey0000

It didn't work for me, although the longTouch option was set to true.

I changed the bindDrag function in the ng-sortable.js file to bind longTouchStart and longTouchCancel to the 'touchstart' and 'touchend' events. Now the drag & drop also works on mobile for me.

Before change:

bindDrag = function () {
            if (hasTouch) {
              if (isLongTouch) {
                if (isIOS) {
                  element.bind('touchstart', longTouchStart);
                  element.bind('touchend', longTouchCancel);
                  element.bind('touchmove', longTouchCancel);
                } else {
                  element.bind('contextmenu', dragListen);
                }
              } else {
                element.bind('touchstart', dragListen);
              }
            }
            element.bind('mousedown', dragListen);
          };

After change:

bindDrag = function () {
              element.bind('touchstart', longTouchStart);
              element.bind('touchend', longTouchCancel);
              element.bind('touchmove', longTouchCancel);
              element.bind('contextmenu', dragListen);
              element.bind('touchstart', dragListen);
            element.bind('mousedown', dragListen);
          };

So it seems that some of touch events were bound only on iOS devices. Binding them on every device has solved the problem for me. Maybe there were changes in the events that the browsers produce.

iwanmcm avatar Apr 14 '20 14:04 iwanmcm