fatlinesofcode / ngDraggable

Drag and drop module for Angular JS
MIT License
631 stars 400 forks source link

ng-drag-success / ng-drop-success callback not fired on touch/mobile device #148

Open yashikagarg13 opened 9 years ago

yashikagarg13 commented 9 years ago

Hi

When I test my code in device mode of chorme, onDragSuccess and onDropSuccess never get fired. Also, on "draggable:start" I get this as $event

   Object {
      data: Object
      element: m.fn.init[1]
      event: m.Event
      tx: NaN
      ty: NaN
      x: undefined
      y: undefined
  }

Any ideas what could be the reason? Is it anything related to order of jQuery and angular.js. I am using jQuery and do not want to use JQLite but full jQuery version

yashikagarg13 commented 9 years ago

@fatlinesofcode Please reply on this asap!

yashikagarg13 commented 9 years ago

I am failing this test

  var hitTest = function(x, y) {
                    var bounds = element[0].getBoundingClientRect();// ngDraggable.getPrivOffset(element);
                    x -= $document[0].body.scrollLeft + $document[0].documentElement.scrollLeft;
                    y -= $document[0].body.scrollTop + $document[0].documentElement.scrollTop;
                    return  x >= bounds.left
                            && x <= bounds.right
                            && y <= bounds.bottom
                            && y >= bounds.top;
                };

What is it about?

yashikagarg13 commented 9 years ago

@fatlinesofcode

SandrineProusteau commented 8 years ago

Having the issue, try replacing

$document.on(_moveEvents, onmove);
$document.on(_releaseEvents, onrelease);

in onlongpress function by

if(_hasTouch){
                      if (_dragHandle) {
                        _dragHandle.on(_moveEvents, onmove);
                        _dragHandle.on(_releaseEvents, onrelease);
                      }else{
                        element.on(_moveEvents, onmove);
                        element.on(_releaseEvents, onrelease);
                      }
                    }else{
                      $document.on(_moveEvents, onmove);
                      $document.on(_releaseEvents, onrelease);
                    }
mhudnell commented 8 years ago

I'm having the same issue with onDragSuccess and onDropSuccess never getting called. I'm developing for mobile using Ionic. I tried your solution @SandrineProusteau, but it didn't fix it for me.

mhudnell commented 8 years ago

For me the problem was here in the onDragEnd function:

if (!_dropEnabled || _myid === obj.uid) {
    updateDragStyles(false, obj.element);
    return;
}

_myid === obj.uid was always evaluating to true, so the function kept returning early. I removed this check and it works now.

Naveenbc commented 7 years ago

@yashikagarg13 I am also failing same test. Can you help me out. And this is happening in only IE.