1

My images move around the page in different directions. When two images collide I want to throw an alert.

Images are loaded like this:

    <?php foreach($logos as $logo) { $id = $logo['Id']; $logoName = $logo['Logo_Link']; ?>
        <img  class="imglogo" src="images/<?php echo $logoName ?>" />
    <?php } ?>

Is there anyway with JavaScript I could detect when any of the elements overlap?

Sabir Al Fateh
  • 1,743
  • 3
  • 20
  • 27
Ant Nobby
  • 23
  • 3
  • Is it intended behavior to make the images "move around the page in different directions"? – Aditya Oct 30 '18 at 11:39
  • Even better if you add a screenshot showing non colliding images and colliding images. – Aditya Oct 30 '18 at 11:39
  • Yes, it is. When two images touch I need to log an alert – Ant Nobby Oct 30 '18 at 11:54
  • 1
    Possible duplicate of [jQuery/JavaScript collision detection](https://stackoverflow.com/questions/4230029/jquery-javascript-collision-detection) – AmmoPT Oct 30 '18 at 12:15
  • You can try to use [intersection observe API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) or there is a polyfill for browsers that don't supports it – jcubic Oct 30 '18 at 12:22

0 Answers0