You can try jquery-collision plus jquery-ui-draggable- collision . Full disclosure: I just wrote and released them on sourceforge.
The first allows this:
var hit_list = $("#collider").collision(".obstacle");
which is a list of all the ".obstacle" that overlap the "#collider".
The second allows you to:
$("#collider").draggable( { obstacle: ".obstacle" } );
What gives you (incidentally) a βcollisionβ event to bind to:
$("#collider").bind( "collision", function(event,ui){...} );
And you can even install:
$("#collider").draggable( { obstacle: ".obstacle", preventCollision: true } );
to prevent "#collider" from ever overlapping ".obstacle" when dragging.
eruciform
source share