Skip to content

Instantly share code, notes, and snippets.

@Lokua
Created May 18, 2018 15:44
Show Gist options
  • Save Lokua/c76510c55314c02b73a9734caccee2e8 to your computer and use it in GitHub Desktop.
Save Lokua/c76510c55314c02b73a9734caccee2e8 to your computer and use it in GitHub Desktop.
export function isEventWithin(e, element) {
const rect = element.getBoundingClientRect()
return (
rect.top <= e.clientY &&
e.clientY <= rect.top + rect.height &&
rect.left <= e.clientX &&
e.clientX <= rect.left + rect.width
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment