cleaned up drag/drop code

This commit is contained in:
Dan Walkowski 2010-03-31 16:16:42 -07:00
parent 34935fdee3
commit d219e8fe08

View File

@ -470,45 +470,18 @@ window.Groups = {
greedy: true,
drop: function(e){
$target = $(e.target);
$dragged.removeClass("willGroup")
// Only drop onto the top z-index
if( $target.css("zIndex") < $dragged.data("topDropZIndex") ) return;
$dragged.data("topDropZIndex", $target.css("zIndex") );
$dragged.data("topDrop", $target);
// This strange timeout thing solves the problem of when
// something is dropped onto multiple potential drop targets.
// We wait a little bit to see get all drops, and then we have saved
// the top-most one and drop onto that.
clearTimeout( timeout );
var dragged = $dragged;
var target = $target;
timeout = setTimeout( function(){
dragged.removeClass("willGroup")
dragged.animate({
top: target.position().top+15,
left: target.position().left+15,
}, 100);
setTimeout( function(){
var group = $(target).data("group");
var group = $target.data("group");
if( group == null ){
var group = new Group([target, dragged]);
var group = new Group([$target, $dragged]);
} else {
group.add( dragged );
group.add( $dragged );
}
}, 100);
}, 10 );
},
over: function(e){
$dragged.addClass("willGroup");
$dragged.data("topDropZIndex", 0);
},
out: function(){
$dragged.removeClass("willGroup");