Last active
December 20, 2015 15:38
-
-
Save eaigner/6155120 to your computer and use it in GitHub Desktop.
Draggable directive for AngularJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: ng-draggable="dragFile($event)" | |
App.directive('ngDraggable', function ($parse) { | |
return { | |
restrict: 'A', | |
link: function (scope, elem, attrs) { | |
var fn = $parse(attrs.ngDraggable); | |
elem[0].draggable = true; | |
elem.bind('dragstart', function (event) { | |
scope.$apply(function () { | |
fn(scope, {$event:event}); | |
}); | |
}); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment