diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 390c85a05..4677eaf30 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -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; + } });