Skip to content

Commit

Permalink
Merge branch 'master' of github.com:fatlinesofcode/ngDraggable
Browse files Browse the repository at this point in the history
  • Loading branch information
fatlinesofcode committed Mar 12, 2015
2 parents 33de6ef + 8818977 commit a661e02
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ngDraggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ angular.module("ngDraggable", [])
var _pressEvents = 'touchstart mousedown';
var _moveEvents = 'touchmove mousemove';
var _releaseEvents = 'touchend mouseup';
var _dragHandle;

// to identify the element in order to prevent getting superflous events when a single element has both drag and drop directives on it.
var _myid = scope.$id;
Expand All @@ -46,6 +47,11 @@ angular.module("ngDraggable", [])

var initialize = function () {
element.attr('draggable', 'false'); // prevent native drag
// check to see if drag handle(s) was specified
var dragHandles = element.find('[ng-drag-handle]');
if (dragHandles.length) {
_dragHandle = dragHandles;
}
toggleListeners(true);
};

Expand All @@ -57,7 +63,14 @@ angular.module("ngDraggable", [])
scope.$watch(attrs.ngDrag, onEnableChange);
scope.$watch(attrs.ngCenterAnchor, onCenterAnchor);
scope.$watch(attrs.ngDragData, onDragDataChange);
element.on(_pressEvents, onpress);
// wire up touch events
if (_dragHandle) {
// handle(s) specified, use those to initiate drag
_dragHandle.on(_pressEvents, onpress);
} else {
// no handle(s) specified, use the element as the handle
element.on(_pressEvents, onpress);
}
if(! _hasTouch && element[0].nodeName.toLowerCase() == "img"){
element.on('mousedown', function(){ return false;}); // prevent native drag for images
}
Expand Down Expand Up @@ -268,7 +281,7 @@ angular.module("ngDraggable", [])
}

$timeout(function(){
onDropCallback(scope, {$data: obj.data, $event: obj});
onDropCallback(scope, {$data: obj.data, $event: obj, $target: scope.$eval(scope.value)});
});
}
$timeout(function(){
Expand Down

0 comments on commit a661e02

Please sign in to comment.