fatlinesofcode / ngDraggable

Drag and drop module for Angular JS
MIT License
630 stars 399 forks source link

Could we adjust through config the drag enable delay in scope ? #257

Closed smartinus44 closed 8 years ago

smartinus44 commented 8 years ago

Hi,

I am working on Window 10 with Chrome Version 52.0.2743.82 m (64-bit) on a laptop. I have _hasTouch always true due to my Chrome configuration setup in automatic (chrome://flags/#touch-events). The problem is the timer of 100 is a little bit long for user using a mouse :-(

I think its a bug.

My question is: is it possible to set up this delay (currently arbitrarily set up to 100) in a variable defined earlier in the scope ?

.directive('ngDrag', ['$rootScope', '$parse', '$document', '$window', 'ngDraggable', function ($rootScope, $parse, $document, $window, ngDraggable) {

...
    var _dragEnableDelay = scope.dragEnableDelay; // time in ms after the dragging gets started
...

    if(_hasTouch){
        cancelPress();
        _pressTimer = setTimeout(function(){
            cancelPress();
            onlongpress(evt);
        },_dragEnableDelay); **//INSTEAD OF 100**
        $document.on(_moveEvents, cancelPress);
        $document.on(_releaseEvents, cancelPress);
    }else{
        onlongpress(evt);
    }

...

}

I have read the following bug which explain why the flash is always set to false with chrome.

Thanx for your answer !

Kind Regards,

daniel-ang commented 8 years ago

I have the same issue with Chrome. This is a good suggestion. Even after changing time to 0, there's still a small delay from the setTimeout which can only be removed by changing the "if (_hasTouch) ..." condition to false. I suggest adding an option to distinguish between touch mobile devices (phones, tables) and desktop devices which uses a mouse. Something along the lines of:

if(_hasTouch && _isMobile) ...

fatlinesofcode commented 8 years ago

delay can now be adjusted via the ngDraggable service, e.g. ngDraggable.touchTimeout = 100