New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dom-plane

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-plane

DOM and window coordinate helpers

1.0.0
npm
Version published
Maintainers
1
Created
Source

Example

import {
    createPointCB,
    getClientRect,
    pointInside
} from 'dom-plane';

const point = {};
const pointCB = createPointCB(point);

window.addEventListener('mousemove', pointCB);
window.addEventListener('mousedown', (e)=>{
    console.log('point is inside '+e.target, '=', pointInside(point, e.target))
    console.log('current rect ', getClientRect(e.target))
})

Exported functions.

  • createPointCB(point)
  • getClientRect(element)
  • pointInside(point, element)

createPointCB(point) -> pointCB

point should be an object. Preferably an empty object.

createPointCB returns a function that should be set as a listener on mouse, or touch events.

Each time the event fires it on pointCB it will update point.

point

point will gain these properties:

  • target
  • element
  • type
  • pageX
  • pageY
  • x
  • y

getClientRect(element|window) -> clientRect

Get the boundingClientRect of the element, or window.

pointInside(point, element) -> Boolean

Check to see if the point is inside the element.

Keywords

DOM

FAQs

Package last updated on 04 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts