Check if pointer is near the element
npm install --save is-pointer-near
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);
Return true
if pointer is within distance
from element
Type: element
DOM element.
Type: object
Pointer event.
Type: number
Default: 50
Distance to the element
.
- coordinates — calculate relative coordinates
- global-offset — element global offset
- is-pointer-inside — check if pointer is inside the element
MIT