I have many div's that are basically identical and are spread across the screen. Each one is jQuery draggable on the x-axis. You could imagine it as a ui-slider with many handles. How can I write a function that will check whether when anyone of the div's which I may be dragging has overlapped any other div or div's?
I would like a to have a global status indicating if any are over lapping and also a way to determine the id's of only the div's which overlap.
This is what I have created so far but I don't quite understand the algorhytm of comparing widths/heights/offsets etc. Please, I need help.
<div class="dragable">
<div class="dragable">
<div class="dragable">
<div class="dragable">
--
function collisionChecker(activeDiv, anyOtherDiv) {
//do activeDiv and anyOtherDiv overlap? Yes - return true
}
$('.dragable').draggable({
drag: function( event, ui ) {
$('.dragable').not(this).each(function(){
$('#result').text( collisionChecker($(ui.helper), $(this)) );
});
}
});