diff --git a/src/angular-dragdrop.js b/src/angular-dragdrop.js index 5522936..e023bd1 100644 --- a/src/angular-dragdrop.js +++ b/src/angular-dragdrop.js @@ -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, @@ -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'); @@ -328,12 +328,7 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti } }); } else { - element.draggable({disabled: true}); - } - - if (killWatcher && angular.isDefined(newValue) && (angular.equals(attrs.drag, 'true') || angular.equals(attrs.drag, 'false'))) { - killWatcher(); - killWatcher = null; + dragSettings = scope.$eval(element.attr('jqyoui-draggable') || element.attr('data-jqyoui-draggable')) || {}; jqyouiOptions = scope.$eval(attrs.jqyouiOptions) || {}; element .draggable({disabled: true}) .draggable(jqyouiOptions); } }; @@ -392,18 +387,13 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti } }); } else { - element.droppable({disabled: true}); - } - - if (killWatcher && angular.isDefined(newValue) && (angular.equals(attrs.drop, 'true') || angular.equals(attrs.drop, 'false'))) { - killWatcher(); - killWatcher = null; + dropSettings = scope.$eval($(element).attr('jqyoui-droppable') || $(element).attr('data-jqyoui-droppable')) || {}; jqyouiOptions = scope.$eval(attrs.jqyouiOptions) || {}; element .droppable({disabled: true}) .droppable(jqyouiOptions); } }; killWatcher = scope.$watch(function() { return scope.$eval(attrs.drop); }, updateDroppable); updateDroppable(); - + element.on('$destroy', function() { element.droppable({disabled: true}).droppable('destroy'); });