Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
components
todo.TODO
.idea
13 changes: 9 additions & 4 deletions src/angular-dragdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti
callback = objExtract.callback,
constructor = objExtract.constructor,
args = [event, ui].concat(objExtract.args);

// call either $scoped method i.e. $scope.dropCallback or constructor's method i.e. this.dropCallback.
// Removing scope.$apply call that was performance intensive (especially onDrag) and does not require it
// always. So call it within the callback if needed.
return (scope[callback] || scope[constructor][callback]).apply(scope[callback] ? scope : scope[constructor], args);

function extract(callbackName) {
var atStartBracket = callbackName.indexOf('(') !== -1 ? callbackName.indexOf('(') : callbackName.length,
atEndBracket = callbackName.lastIndexOf(')') !== -1 ? callbackName.lastIndexOf(')') : callbackName.length,
Expand Down Expand Up @@ -195,7 +195,7 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti
toPos.top+= $toEl.outerHeight(true);
}
} else {
// Angular v1.2 uses ng-hide to hide an element
// Angular v1.2 uses ng-hide to hide an element
// so we've to remove it in order to grab its position
if (hadNgHideCls) $toEl.removeClass('ng-hide');
if (hadDNDHideCls) $toEl.removeClass('angular-dragdrop-hide');
Expand Down Expand Up @@ -314,6 +314,8 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti
.draggable({
start: function(event, ui) {
ngDragDropService.draggableScope = scope;
ngDragDropService.dataStransfer = {};
event.dataTransfer = ngDragDropService.dataStransfer;
zIndex = $(jqyouiOptions.helper ? ui.helper : this).css('z-index');
$(jqyouiOptions.helper ? ui.helper : this).css('z-index', 9999);
jqyoui.startXY = $(this)[dragSettings.containment || 'offset']();
Expand Down Expand Up @@ -361,12 +363,15 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti
.droppable(jqyouiOptions)
.droppable({
over: function(event, ui) {
event.dataTransfer = ngDragDropService.dataStransfer;
ngDragDropService.callEventCallback(scope, dropSettings.onOver, event, ui);
},
out: function(event, ui) {
event.dataTransfer = ngDragDropService.dataStransfer;
ngDragDropService.callEventCallback(scope, dropSettings.onOut, event, ui);
},
drop: function(event, ui) {
event.dataTransfer = ngDragDropService.dataStransfer;
var beforeDropPromise = null;

if (dropSettings.beforeDrop) {
Expand Down Expand Up @@ -403,7 +408,7 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti

killWatcher = scope.$watch(function() { return scope.$eval(attrs.drop); }, updateDroppable);
updateDroppable();

element.on('$destroy', function() {
element.droppable({disabled: true}).droppable('destroy');
});
Expand Down