No description, website, or topics provided.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
src
.babelrc
.editorconfig
.gitignore
README.md
package-lock.json
package.json
rollup.config.js
screenshot.gif

README.md

is-inside-dom-element

NPM JavaScript Style Guide

screenshot

Description

Sometimes you need programmatic way to determine whether the mouse cursor is hovering above a DOM element. Instead of using onmouseover or onmouseleave this lib uses geometry to determine this.

It's a rudimentary implementation since it only works on rectangular DOM elements.

Demo

https://wle8300.github.io/is-inside-dom-element

Install

npm install --save is-inside-dom-element

Usage

//calling
import isInside from 'is-inside-dom-element'

//usage
document.addEventListener('mousemove', (event) => {

  const element = document.getElementById('some-id')

  console.log(isInside(event.x, event.y, element))
})

License

MIT © wle8300