# e-vector-dom

> Vector utilities to work with DOM elements.

Latest version **1.0.1** (published 2019-06-24) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install e-vector-dom
pnpm add e-vector-dom
yarn add e-vector-dom
bun add e-vector-dom
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-06-24 |
| First published | 2019-06-24 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | debjitbis08 |
| Keywords | vector, maths |

## Links

- npm: https://www.npmjs.com/package/e-vector-dom
- Repository: https://github.com/bonzaico/e-vector
- Homepage: https://github.com/bonzaico/e-vector#readme
- Issues: https://github.com/bonzaico/e-vector/issues
- npm.io page: https://npm.io/package/e-vector-dom

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-06-24
- 1.0.0 — 2019-06-24

## README

# e-vector-dom

DOM related utilities for [e-vector](https://github.com/bonzaico/e-vector).

## API Docs

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

- [e-vector-dom](#e-vector-dom)
    - [API Docs](#api-docs)
            - [Table of Contents](#table-of-contents)
        - [elCenter](#elcenter)
        - [mousePositionFromEvent](#mousepositionfromevent)
        - [positionFromClientRect](#positionfromclientrect)
        - [elAngle](#elangle)

### elCenter

[packages/e-vector-dom/src/e-vector-dom.js:12-29](https://github.com/bonzaico/e-vector/blob/bf4190a975c926b40a420042b90698506e868090/packages/e-vector-dom/src/e-vector-dom.js#L12-L29 "Source code on GitHub")

Get center of an HTML element as a Vector, relative to the viewport.

**Parameters**

-   `el` **[HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element)** 

Returns **Vector** 

### mousePositionFromEvent

[packages/e-vector-dom/src/e-vector-dom.js:43-44](https://github.com/bonzaico/e-vector/blob/bf4190a975c926b40a420042b90698506e868090/packages/e-vector-dom/src/e-vector-dom.js#L43-L44 "Source code on GitHub")

Create a vector of the mouse position from the event object of a mouse event.

**Parameters**

-   `e` **[MouseEvent](https://developer.mozilla.org/docs/Web/API/MouseEvent)** Event object

**Examples**

```javascript
el.addEventListener("mousedown", e => {
    const position = Vector.mousePositionFromEvent(e);
});
```

Returns **Vector** 

### positionFromClientRect

[packages/e-vector-dom/src/e-vector-dom.js:56-57](https://github.com/bonzaico/e-vector/blob/bf4190a975c926b40a420042b90698506e868090/packages/e-vector-dom/src/e-vector-dom.js#L56-L57 "Source code on GitHub")

Create a vector for the position of a client rectangle.

**Parameters**

-   `rect` **ClientRect** 

**Examples**

```javascript
const position = Vector.positionFromClientRect(el.getBoundingClientRect());
```

Returns **Vector** 

### elAngle

[packages/e-vector-dom/src/e-vector-dom.js:66-71](https://github.com/bonzaico/e-vector/blob/bf4190a975c926b40a420042b90698506e868090/packages/e-vector-dom/src/e-vector-dom.js#L66-L71 "Source code on GitHub")

Find the angle between the given vector and the center of an DOM element

**Parameters**

-   `el` **[HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element)** 
-   `v` **VectorT** 

Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Angle in degrees

---
_Source: https://npm.io/package/e-vector-dom · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
