Skip to content Skip to sidebar Skip to footer

How To Detect Div Collision In My Case?

I want to detect the div collision when user drag their mouse. I have something like
).draggable({ drag: function (event, ui) { var height = ui.helper.height(); var divs = $('div.img').not($(this).children()); var pos = ui.position; divs.each(function (index, value) { var t = $(this).position(); var hei = $(this).height() if (t.top <= pos.top + height ) { // check for top collision if (pos.left <= t.left + $(this).width()) { // check for side collision console.log('hit the object'); } } }); } });

And a Demo


Solution 2:


Post a Comment for "How To Detect Div Collision In My Case?"