mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Draggable: Added axis backCompat
This commit is contained in:
parent
8a8a26f9da
commit
44330395e1
49
ui/jquery.ui.draggable.js
vendored
49
ui/jquery.ui.draggable.js
vendored
@ -474,3 +474,52 @@ $.widget( "ui.draggable", $.ui.draggable, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
})( jQuery );
|
})( jQuery );
|
||||||
|
|
||||||
|
// DEPRECATED
|
||||||
|
if ( $.uiBackCompat !== false ) {
|
||||||
|
|
||||||
|
// axis option
|
||||||
|
$.widget( "ui.draggable", $.ui.draggable, {
|
||||||
|
options: {
|
||||||
|
axis: false
|
||||||
|
},
|
||||||
|
|
||||||
|
_create : function() {
|
||||||
|
|
||||||
|
var start_left, start_top;
|
||||||
|
|
||||||
|
this._super();
|
||||||
|
|
||||||
|
// If movement should only move left/right
|
||||||
|
if ( this.options.axis === 'x' ) {
|
||||||
|
|
||||||
|
// Cache starting top position to keep it from moving
|
||||||
|
this.element.on( 'dragbeforestart', function( e, ui ) {
|
||||||
|
start_top = ui.position.top;
|
||||||
|
});
|
||||||
|
|
||||||
|
// On drag, make sure top does not change so axis is locked
|
||||||
|
this.element.on( 'drag', function( e, ui ) {
|
||||||
|
ui.position.top = start_top;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
// If movement should only move up/down
|
||||||
|
else if ( this.options.axis === 'y' ) {
|
||||||
|
|
||||||
|
// Cache starting left position to keep it from moving
|
||||||
|
this.element.on( 'dragbeforestart', function( e, ui ) {
|
||||||
|
start_left = ui.position.left;
|
||||||
|
});
|
||||||
|
|
||||||
|
// On drag, make sure top does not change so axis is locked
|
||||||
|
this.element.on( 'drag', function( e, ui ) {
|
||||||
|
ui.position.left = start_left;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user