mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Draggable: Added stack backCompat
This commit is contained in:
parent
50e2e91e85
commit
68f45613bd
51
ui/jquery.ui.draggable.js
vendored
51
ui/jquery.ui.draggable.js
vendored
@ -252,8 +252,7 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
||||
},
|
||||
|
||||
_handleScrolling: function( pointerPosition ) {
|
||||
var self = this,
|
||||
scrollTop = this.scrollParent.scrollTop(),
|
||||
var scrollTop = this.scrollParent.scrollTop(),
|
||||
scrollLeft = this.scrollParent.scrollLeft(),
|
||||
scrollSensitivity = this.scrollSensitivity,
|
||||
// overflowOffset is only set when scrollParent is not doc/html
|
||||
@ -882,4 +881,52 @@ if ( $.uiBackCompat !== false ) {
|
||||
|
||||
});
|
||||
|
||||
// stack option
|
||||
$.widget( "ui.draggable", $.ui.draggable, {
|
||||
options: {
|
||||
stack: false
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
|
||||
var self = this;
|
||||
|
||||
this._super();
|
||||
|
||||
this.element.on( "dragbeforestart", function( event, ui ) {
|
||||
|
||||
var stack = self.options.stack,
|
||||
group, min;
|
||||
|
||||
if ( !self.options.stack ) {
|
||||
return;
|
||||
}
|
||||
|
||||
group = $.makeArray( $(stack) ).sort(function(a,b) {
|
||||
|
||||
var aZIndex = parseInt( $(a).css("zIndex"), 10 ),
|
||||
bZIndex = parseInt( $(b).css("zIndex"), 10 ),
|
||||
min;
|
||||
|
||||
return ( aZIndex || 0) - ( bZIndex|| 0);
|
||||
});
|
||||
|
||||
if (!group.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
min = parseInt(group[0].style.zIndex, 10) || 0;
|
||||
|
||||
$(group).each(function(i) {
|
||||
this.style.zIndex = min + i;
|
||||
});
|
||||
|
||||
self.element[0].style.zIndex = min + group.length;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user