Skip to content

Commit

Permalink
Merge pull request #118 from cdauth/avoid-digest-undefined-callbacks
Browse files Browse the repository at this point in the history
Avoiding digest cycles for undefined callbacks
  • Loading branch information
fatlinesofcode committed Mar 31, 2015
2 parents d757428 + 87c2414 commit bb0b719
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions ngDraggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,22 @@ angular.module("ngDraggable", [])
var onDragStart = function(evt, obj) {
if(! _dropEnabled)return;
isTouching(obj.x,obj.y,obj.element);

$timeout(function(){
onDragStartCallback(scope, {$data: obj.data, $event: obj});
});

if (attrs.ngDragStart) {
$timeout(function(){
onDragStartCallback(scope, {$data: obj.data, $event: obj});
});
}
};
var onDragMove = function(evt, obj) {
if(! _dropEnabled)return;
isTouching(obj.x,obj.y,obj.element);
$timeout(function(){
onDragMoveCallback(scope, {$data: obj.data, $event: obj});
});

if (attrs.ngDragMove) {
$timeout(function(){
onDragMoveCallback(scope, {$data: obj.data, $event: obj});
});
}
};

var onDragEnd = function (evt, obj) {
Expand All @@ -299,13 +304,19 @@ angular.module("ngDraggable", [])
obj.callback(obj);
}

if (attrs.ngDropSuccess) {
$timeout(function(){
onDropCallback(scope, {$data: obj.data, $event: obj, $target: scope.$eval(scope.value)});
});
}
}

if (attrs.ngDragStop) {
$timeout(function(){
onDropCallback(scope, {$data: obj.data, $event: obj, $target: scope.$eval(scope.value)});
onDragStopCallback(scope, {$data: obj.data, $event: obj});
});
}
$timeout(function(){
onDragStopCallback(scope, {$data: obj.data, $event: obj});
});

updateDragStyles(false, obj.element);
};

Expand Down

0 comments on commit bb0b719

Please sign in to comment.