mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Draggable: If beforeStart is stopped by user, and appendTo is set, dragEl will be reset to proper position anyway
This commit is contained in:
parent
c07ae398fa
commit
fb2eca6552
36
ui/jquery.ui.draggable.js
vendored
36
ui/jquery.ui.draggable.js
vendored
@ -116,7 +116,12 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
|||||||
// If user cancels beforeStart, don't allow dragging
|
// If user cancels beforeStart, don't allow dragging
|
||||||
if ( this._trigger( "beforeStart", event,
|
if ( this._trigger( "beforeStart", event,
|
||||||
this._originalHash( pointerPosition ) ) === false ) {
|
this._originalHash( pointerPosition ) ) === false ) {
|
||||||
|
|
||||||
|
// domPosition needs to be undone even if beforeStart is stopped
|
||||||
|
// Otherwise this.dragEl will remain in the element appendTo is set to
|
||||||
|
this._resetDomPosition();
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._setCss();
|
this._setCss();
|
||||||
@ -126,6 +131,25 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
|||||||
this._trigger( "start", event, this._fullHash( pointerPosition ) );
|
this._trigger( "start", event, this._fullHash( pointerPosition ) );
|
||||||
this._blockFrames();
|
this._blockFrames();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_resetDomPosition : function() {
|
||||||
|
|
||||||
|
// Nothing to do in this case
|
||||||
|
if ( !this.domPosition ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent = this.domPosition.parent;
|
||||||
|
next = parent.children().eq( this.domPosition.index );
|
||||||
|
if ( next.length ) {
|
||||||
|
next.before( this.element );
|
||||||
|
} else {
|
||||||
|
parent.append( this.element );
|
||||||
|
}
|
||||||
|
this.element.offset( this.offset );
|
||||||
|
this.domPosition = null;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
_move: function( event, pointerPosition ) {
|
_move: function( event, pointerPosition ) {
|
||||||
this._preparePosition( pointerPosition );
|
this._preparePosition( pointerPosition );
|
||||||
@ -151,17 +175,7 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
|||||||
if ( this.options.helper ) {
|
if ( this.options.helper ) {
|
||||||
this.dragEl.remove();
|
this.dragEl.remove();
|
||||||
}
|
}
|
||||||
if ( this.domPosition ) {
|
this._resetDomPosition();
|
||||||
parent = this.domPosition.parent;
|
|
||||||
next = parent.children().eq( this.domPosition.index );
|
|
||||||
if ( next.length ) {
|
|
||||||
next.before( this.element );
|
|
||||||
} else {
|
|
||||||
parent.append( this.element );
|
|
||||||
}
|
|
||||||
this.element.offset( this.offset );
|
|
||||||
this.domPosition = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._unblockFrames();
|
this._unblockFrames();
|
||||||
|
Loading…
Reference in New Issue
Block a user