Draggable: Added stack backCompat

This commit is contained in:
Dave Stein 2012-12-20 18:02:00 -05:00
parent 50e2e91e85
commit 68f45613bd

View File

@ -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;
});
}
});
}