1.0.2 • Published 6 years ago

is-inside-dom-element v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago