Created
November 19, 2014 16:30
-
-
Save arunsivasankaran/2044d998e7f4e65a39da to your computer and use it in GitHub Desktop.
Simple Drag and Drop
This file contains 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
var Module = angular.module('simple-drag-drop', []); | |
Module.directive('draggable', function(draggingStudent) { | |
return { | |
restrict: 'A', | |
link: function(scope, element, attrs) { | |
element.draggable({ | |
revert: "invalid", | |
helper:"clone", | |
start: function() { | |
// <foo draggable on-drag='thingsThatsdragging=student'> | |
scope.$eval(attrs.onDragstart); | |
draggingStudent.student = scope.student; | |
draggingStudent.cohort = scope.cohort; | |
$(this).addClass("dragging") | |
}, | |
stop: function() { | |
scope.$eval(attrs.onStop); | |
// $(this).removeClass("dragging") | |
}, | |
drag: function() { | |
scope.$eval(attrs.onDrag); | |
$(this).addClass("dragging") | |
} | |
}); | |
} | |
} | |
}); | |
Module.directive('droppable', function() { | |
return { | |
restrict: 'A', | |
link: function(scope, element, attrs) { | |
element.droppable({ | |
hoverClass: "draghover", | |
drop: function() { | |
scope.$eval(attrs.onDrop); | |
$(".dragging").removeClass("dragging"); | |
} | |
}) | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment