@untemps/utils - v3.1.0
    Preparing search index...

    Function doElementsOverlap

    • Parameters

      • element1: Element

        The first DOM element to compare.

      • element2: Element

        The second DOM element to compare.

      Returns boolean

      true if the two DOM elements overlap.

      import { doElementsOverlap } from '@untemps/utils/dom/doElementsOverlap'

      const element1 = document.createElement('div')
      element1.style = 'width: 140px; height: 140px; position: absolute; background-color: red;'
      document.body.appendChild(element1)

      const element2 = document.createElement('div')
      element2.style = 'width: 130px; height: 130px; position: absolute; background-color: green;'
      document.body.appendChild(element2)

      const element3 = document.createElement('div')
      element3.style = 'width: 130px; height: 130px; left: 250px; top: 250px; position: absolute; background-color: blue;'
      document.body.appendChild(element3)

      doElementsOverlap(element1, element2) // true
      doElementsOverlap(element1, element3) // false