I’m very new to JavaScript so forgive me if this question is naive/obvious. I’m using jQuery UI drag and drop (and the jQuery Collision Detection library from this site: http://eruciform.com/static//jquerycollision/jquery-collision-drag-collision-example.html). Although I have no problems detecting which divs are colliding with each other (and doing things to said divs with ($(this).collisions(“.collisionclass”)).each(function() …)), I haven’t been able to find this list of divs that have NOT collided with each other or the target collider, at least not an elegant solution (and the reason is I wanted to do other actions on those remaining, uncollided divs).
Does anyone know of an elegant way to find which divs have not collided without resorting to brute force (e.g., add all such divs to a collection and every time there is a collision event check which ones from original collection are not in the resulting collision collection)? The example source code via the link above seems to simply add and remove dynamic div overlays on portions of original divs that are collided, but that doesn’t tell me how to detect not-collided divs…
You can use the jquery not method.
Technically this will check all the items if they have the “collisionclass” class, however it is still efficient until you get to huge numbers of items.