is-inside-dom-element

1.0.2 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i is-inside-dom-element

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

7.96 kB

Total Files

6

Last publish

Collaborators

  • wle8300