e-vector-dom
v1.0.1
Published
Vector utilities to work with DOM elements.
Downloads
4
Readme
e-vector-dom
DOM related utilities for e-vector.
API Docs
Table of Contents
elCenter
packages/e-vector-dom/src/e-vector-dom.js:12-29
Get center of an HTML element as a Vector, relative to the viewport.
Parameters
el
HTMLElement
Returns Vector
mousePositionFromEvent
packages/e-vector-dom/src/e-vector-dom.js:43-44
Create a vector of the mouse position from the event object of a mouse event.
Parameters
e
MouseEvent Event object
Examples
el.addEventListener("mousedown", e => {
const position = Vector.mousePositionFromEvent(e);
});
Returns Vector
positionFromClientRect
packages/e-vector-dom/src/e-vector-dom.js:56-57
Create a vector for the position of a client rectangle.
Parameters
rect
ClientRect
Examples
const position = Vector.positionFromClientRect(el.getBoundingClientRect());
Returns Vector
elAngle
packages/e-vector-dom/src/e-vector-dom.js:66-71
Find the angle between the given vector and the center of an DOM element
Parameters
el
HTMLElementv
VectorT
Returns number Angle in degrees