0

How to detect when an element over another element in JavaScript.

How to detect if an element is over circle div element using JavaScript. From image ( https://i.ibb.co/5MZkrcg/My-drawing.jpg ) yellow circle is moving randomly. When it come on red circle, it's color will be change to blue.

14th Jun 2021, 8:51 AM
Coder-Rohit[{(∞)}]
Coder-Rohit[{(∞)}] - avatar
4 Answers
+ 2
by doing computations to check if both elements intersect... for circles that s quite simple: if distance beween two centers is less than sum of radius, then circles overlap ;P
14th Jun 2021, 8:57 AM
visph
visph - avatar
0
Wow! It is very simple. Thanks
14th Jun 2021, 9:03 AM
Coder-Rohit[{(∞)}]
Coder-Rohit[{(∞)}] - avatar
0
yes: that's the most simple case... that's why we often use bounding circle (or sphere) to discreminate first more complex cases ^^
14th Jun 2021, 9:05 AM
visph
visph - avatar