is-pointer-near
v0.1.5
Published
Check if pointer is near the element
Downloads
25
Readme
is-pointer-near
Check if pointer is near the element
Install
npm install --save is-pointer-near
Usage
import isPointerNear from 'is-pointer-near';
document.addEventListener('mousemove', event => {
const el = document.querySelector('.hello');
isPointerNear(el, event, 25); // true if pointer near the el
}, false);
API
isPointerNear(element, event[, distance])
Return true
if pointer is within distance
from element
element
Type: element
DOM element.
event
Type: object
Pointer event.
distance
Type: number
Default: 50
Distance to the element
.
Related
- coordinates — calculate relative coordinates
- global-offset — element global offset
- is-pointer-inside — check if pointer is inside the element
License
MIT