JQuery UI Draggable: Stack on Click
Is it possible to trigger a stack routine draggable
on push rather than just drag and drop?
I found this solution, which is basically trying to just copy the library code. (Also missing an important part that I pasted in below). Isn't there a more elegant solution?
By changing the author's code, the following solution works:
function bringFront(elem, stack){
// Brings a file to the stack front
var min, group = $.makeArray($(stack)).sort(function(a, b) {
return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
});
if(group.length < 1) return;
min = parseInt(group[0].style.zIndex, 10) || 0;
$(group).each(function(i) {
this.style.zIndex = min+i;
});
if(elem == undefined) return;
$(elem).css({'zIndex' : min+group.length});
}
But it would be better to name the library method in some way.
+3
source to share
2 answers