In this demo we will use simple collision detection to highlight intersected objects. For simplicity we will use just bounding boxes to detect collision.
Red borders are used to show bounding boxes.
Instructions: Drag and drop a shape, see collusion.
for (var i = 0; i < 10; i++) { layer.add(createShape()); } layer.draw();
layer.on('dragmove', function(e){ var target = e.target; var targetRect = e.target.getClientRect(); layer.children.each(function(group){ // do not check intersection with itself if (group === target) { return; } if (haveIntersection(group.getClientRect(), targetRect)) { group.findOne('.fillShape').fill('red'); } else { group.findOne('.fillShape').fill('grey'); } // do not need to call layer.draw() here // because it will be called by dragmove action }); });