mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Draggable: Proper use of ._trigger for detecting preventDefault. _uiHash now returns position and helper - removed offset.
This commit is contained in:
parent
1337573adc
commit
ec9c1cf6f4
39
ui/jquery.ui.draggable.js
vendored
39
ui/jquery.ui.draggable.js
vendored
@ -124,7 +124,7 @@ $.widget( "ui.draggable", {
|
||||
},
|
||||
|
||||
_mouseDown: function( event ) {
|
||||
var newLeft, newTop;
|
||||
var newLeft, newTop, allowed;
|
||||
|
||||
// Prevent text selection, among other things
|
||||
event.preventDefault();
|
||||
@ -183,11 +183,10 @@ $.widget( "ui.draggable", {
|
||||
|
||||
this._preparePosition( event );
|
||||
|
||||
this._trigger( "start", event, this._uiHash() );
|
||||
allowed = this._trigger( "start", event, this._uiHash() );
|
||||
|
||||
// TODO: should user be able to change position of draggable, if event stopped?
|
||||
// If user stops propagation, leave helper there ( if there's one ), disallow any CSS changes
|
||||
if ( event.cancelBubble === true ) {
|
||||
if ( allowed !== true ) {
|
||||
this.doc.unbind( "." + this.widgetName );
|
||||
return;
|
||||
}
|
||||
@ -201,15 +200,15 @@ $.widget( "ui.draggable", {
|
||||
},
|
||||
|
||||
_mouseMove: function( event ) {
|
||||
var newLeft, newTop;
|
||||
|
||||
var newLeft, newTop, allowed;
|
||||
|
||||
this._preparePosition( event );
|
||||
|
||||
this._trigger( "drag", event, this._uiHash() );
|
||||
|
||||
// TODO: should user be able to change position of draggable, if event stopped?
|
||||
allowed = this._trigger( "drag", event, this._uiHash() );
|
||||
|
||||
|
||||
// If user stops propagation, leave helper there ( if there's one ), disallow any CSS changes
|
||||
if ( event.cancelBubble === true ) {
|
||||
if ( allowed !== true ) {
|
||||
this.doc.unbind( "." + this.widgetName );
|
||||
return;
|
||||
}
|
||||
@ -221,14 +220,15 @@ $.widget( "ui.draggable", {
|
||||
},
|
||||
|
||||
_mouseUp: function( event ) {
|
||||
|
||||
var allowed;
|
||||
|
||||
this._preparePosition( event );
|
||||
|
||||
this._trigger( "stop", event, this._uiHash() );
|
||||
allowed = this._trigger( "stop", event, this._uiHash() );
|
||||
|
||||
// TODO: should user be able to change position of draggable, if event stopped?
|
||||
// If user stops propagation, leave helper there, disallow any CSS changes
|
||||
if ( event.cancelBubble !== true ) {
|
||||
if ( allowed === true ) {
|
||||
|
||||
this._setCss( event );
|
||||
|
||||
@ -293,10 +293,17 @@ $.widget( "ui.draggable", {
|
||||
},
|
||||
|
||||
_uiHash: function( event ) {
|
||||
return {
|
||||
position: this.position,
|
||||
offset: this.offset
|
||||
var ret = {
|
||||
position: this.position
|
||||
// offset: this.offset
|
||||
};
|
||||
|
||||
if ( this.options.helper ) {
|
||||
ret.helper = this.dragEl;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user