Skip to content
This repository was archived by the owner on Jan 28, 2020. It is now read-only.

Commit ab7efd3

Browse files
author
Peter Evans
committed
droppable: drag event; fixes
1 parent b5f1ffd commit ab7efd3

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

ui/droppable.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ $.widget( "ui.droppable", {
4848
deactivate: null,
4949
drop: null,
5050
out: null,
51-
over: null
51+
over: null,
52+
drag: null
5253
},
5354
_create: function() {
5455

@@ -161,6 +162,21 @@ $.widget( "ui.droppable", {
161162

162163
},
163164

165+
_drag: function( event ) {
166+
167+
var draggable = $.ui.ddmanager.current;
168+
169+
// Bail if draggable and droppable are same element
170+
if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
171+
return;
172+
}
173+
174+
if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
175+
this._trigger( "drag", event, this.ui( draggable ) );
176+
}
177+
178+
},
179+
164180
_out: function( event ) {
165181

166182
var draggable = $.ui.ddmanager.current;
@@ -328,6 +344,7 @@ $.ui.ddmanager = {
328344
if ( !this.options ) {
329345
return;
330346
}
347+
331348
if ( !this.options.disabled && this.visible && intersect( draggable, this, this.options.tolerance, event ) ) {
332349
dropped = this._drop.call( this, event ) || dropped;
333350
}
@@ -360,14 +377,18 @@ $.ui.ddmanager = {
360377
// Run through all droppables and check their positions based on specific tolerance options
361378
$.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
362379

363-
if ( this.options.disabled || this.greedyChild || !this.visible ) {
380+
if ( !this.options || this.options.disabled || this.greedyChild || !this.visible ) {
364381
return;
365382
}
366383

367384
var parentInstance, scope, parent,
368385
intersects = intersect( draggable, this, this.options.tolerance, event ),
369386
c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
370387
if ( !c ) {
388+
if (intersects && this.isover) {
389+
this._drag.call(this, event);
390+
}
391+
371392
return;
372393
}
373394

0 commit comments

Comments
 (0)