Skip to content

Commit 50b7e23

Browse files
Fernando Galeanocodef0rmerz
Fernando Galeano
authored andcommitted
fix(droppable): Closes #233 - animate back on beforeDrop-cancel event if jqyouioptions.revertDuration is set
1 parent a03e12d commit 50b7e23

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

demo/dnd-confirmation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ <h2>Default window.confirmation Vs Custom confirmation</h2>
7474
<div class="btn btn-primary" data-drag="true" ng-model="list1" jqyoui-draggable="{animate: true}" ng-hide="!list1.title">{{list1.title}}</div>
7575
</div>
7676
<div class="span6">
77-
<div class="thumbnail" data-drop="true" ng-model="list2" jqyoui-droppable="{beforeDrop: 'beforeDrop'}" ng-bind="list2.title ? 'Dropped successfully..!' : 'Drop here...'"></div>
77+
<div class="thumbnail" data-drop="true" ng-model="list2" jqyoui-droppable="{beforeDrop: 'beforeDrop'}" jqyoui-options="{revertDuration: 1000}" ng-bind="list2.title ? 'Dropped successfully..!' : 'Drop here...'"></div>
7878
</div>
7979
</div>
8080
</div>

src/angular-dragdrop.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,14 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti
348348
priority: 1,
349349
link: function(scope, elem, attrs) {
350350
var element = $(elem);
351-
var dropSettings, killWatcher;
351+
var dropSettings, jqyouiOptions, killWatcher;
352352
var updateDroppable = function(newValue, oldValue) {
353353
if (newValue) {
354354
dropSettings = scope.$eval($(element).attr('jqyoui-droppable') || $(element).attr('data-jqyoui-droppable')) || {};
355+
jqyouiOptions = scope.$eval(attrs.jqyouiOptions) || {};
355356
element
356357
.droppable({disabled: false})
357-
.droppable(scope.$eval(attrs.jqyouiOptions) || {})
358+
.droppable(jqyouiOptions)
358359
.droppable({
359360
over: function(event, ui) {
360361
ngDragDropService.callEventCallback(scope, dropSettings.onOver, event, ui);
@@ -383,7 +384,7 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti
383384
ngDragDropService.callEventCallback(scope, dropSettings.onDrop, event, ui);
384385
}
385386
}), function() {
386-
ui.draggable.css({left: '', top: ''});
387+
ui.draggable.animate({left: '', top: ''}, jqyouiOptions.revertDuration || 0);
387388
});
388389
}
389390
});

0 commit comments

Comments
 (0)