Adding this as a separate answer because it's a totally different approach to the problem.
After I got this working, I tried adding a few other new features, like applying a is-swap
class to the draggable when it's hovering over a non-empty droppable, and applying a is-drop
class to it when it's hovering over an empty one. But because our droppables are so close together, the over
and out
callbacks would get all confused when becoming over
a new droppable before becoming out
of the previous one.
I've realized that what I need to do, should I wish to continue making use of jQuery UI, is not to sub-class draggable or droppable, but rather just use them in a totally new widget. Draggable and droppable are both widgets that get instantiated on many different elements (e.g. each draggable is its own instance, and each droppable is its own instance), but what I need is one widget that contains many draggables and droppables. This will make it far easier to control their states as they interact with each other.
Right now my plan is to create a widget that can be instantiated on some kind of container element, and provide options that allow a consumer of the widget to target the desired elements as draggables and droppables, and simply utilize draggable and droppable in their "natural" state. This will allow me to do things like check the state of one droppable from the callback of another, and fix issues like the out
and over
timing problem I mentioned before.
I'm going to take a stab at implementing this in the next few days, and will update this answer once I have something to show.
Update: here's the much-simplified, much more accurate implementation using this approach. http://jsfiddle.net/isochronous/BQyx2/