From 64e299bf73640e850668710bf5a39778f6aa8e11 Mon Sep 17 00:00:00 2001 From: Ryan Cady Date: Tue, 30 Aug 2016 11:36:27 -0500 Subject: [PATCH] Update ngDrag to use $timeout to hook in with angular, instead of setTimeout setTimeout can cause issues in protractor, because protractor waits for $timeout's to resolve in waitForAngular(), but not setTimeout --- ngDraggable.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ngDraggable.js b/ngDraggable.js index 3f4a2ee..aa60894 100644 --- a/ngDraggable.js +++ b/ngDraggable.js @@ -19,7 +19,7 @@ angular.module("ngDraggable", []) }; }]) - .directive('ngDrag', ['$rootScope', '$parse', '$document', '$window', 'ngDraggable', function ($rootScope, $parse, $document, $window, ngDraggable) { + .directive('ngDrag', ['$rootScope', '$parse', '$document', '$window', 'ngDraggable', '$timeout', function ($rootScope, $parse, $document, $window, ngDraggable, $timeout) { return { restrict: 'A', link: function (scope, element, attrs) { @@ -120,7 +120,7 @@ angular.module("ngDraggable", []) if(_hasTouch){ cancelPress(); - _pressTimer = setTimeout(function(){ + _pressTimer = $timeout(function(){ cancelPress(); onlongpress(evt); },100); @@ -133,7 +133,7 @@ angular.module("ngDraggable", []) }; var cancelPress = function() { - clearTimeout(_pressTimer); + $timeout.cancel(_pressTimer); $document.off(_moveEvents, cancelPress); $document.off(_releaseEvents, cancelPress); };