Skip to content

Instantly share code, notes, and snippets.

@MiniKielbyM
Created June 15, 2023 11:37
Show Gist options
  • Save MiniKielbyM/3344843d024a2475c4b05d2ebf949a1e to your computer and use it in GitHub Desktop.
Save MiniKielbyM/3344843d024a2475c4b05d2ebf949a1e to your computer and use it in GitHub Desktop.
function collide(div1ID, div2) {
const domRect1 = document.getElementById(div1ID).getBoundingClientRect();
const domRect2 = div2.getBoundingClientRect();
return!(
domRect1.top > domRect2.bottom ||
domRect1.right < domRect2.left ||
domRect1.bottom < domRect2.top ||
domRect1.left > domRect2.right
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment