0

I have four divs which are animated using size, height and positions; that means, these divs change their height, width, left and top.

FOCUS:
I want to stop that animation when any of these two divs become overlapped.

HTML:

<div id="container_1">
  <div id="anim_1"></div>
  <div id="anim_2"></div>
</div>

<div id="container_2">
  <div id="anim_3"></div>
  <div id="anim_3"></div>
</div>

If any two anim divs of any container (i.e. container_1 OR container_2) bocome overlapped then I have to stop the animation of both two container divs.

Now, how can I trace out this overlapping using JQUERY or JAVASCRIPT?

Please suggest me.

Thanks in advance.

thecodeparadox
  • 86,271
  • 21
  • 138
  • 164
  • possible duplicate of [Efficiently Detect When Sibling Elements Overlap](http://stackoverflow.com/questions/1560926/efficiently-detect-when-sibling-elements-overlap) – jcolebrand May 03 '11 at 03:58
  • @drachenstern your link is not my desired solution. So this question is not a duplication. The scenario is different from your given link. – thecodeparadox May 03 '11 at 04:07
  • Then feel free to describe how this is not different from that. Remarkably enough, giving code that _demonstrates_ the problem and gives us some insight allows us to make _better decisions_ than when we have to guess. – jcolebrand May 03 '11 at 04:08
  • @drachenstern here I give some code snippet. Now help me. – thecodeparadox May 03 '11 at 04:12
  • 1
    this is almost an exact duplicate of that question. You just need to account for the fact that you're going to be testing for two sets of collisions, not just one. – jcolebrand May 03 '11 at 04:14
  • @drachenstern Now it make me clear. As I'm new to jquery or javascript so I'm not so quick adopter. Thanks for your kind help.So morgar and you both give me the solution.But morgar gives it as answer. So I have to receive it.Thanks again. – thecodeparadox May 03 '11 at 04:18

1 Answers1

2

Take a look to the answer in this other question:

Efficiently Detect When Sibling Elements Overlap

Community
  • 1
  • 1
morgar
  • 2,339
  • 17
  • 16