# @zestia/position-utils

> Basic utils for positioning elements

Latest version **7.0.3** (published 2022-02-22) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @zestia/position-utils
pnpm add @zestia/position-utils
yarn add @zestia/position-utils
bun add @zestia/position-utils
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 7.0.3 |
| Published | 2022-02-22 |
| First published | 2018-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 12 |
| Dependencies | 0 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Zestia |
| Maintainers | philliphaines, amk221, grayt0r |

## Links

- npm: https://www.npmjs.com/package/@zestia/position-utils
- Repository: https://github.com/zestia/position-utils
- Issues: https://github.com/zestia/position-utils/issues
- npm.io page: https://npm.io/package/@zestia/position-utils

## Recent versions

- 7.0.3 (latest) — 2022-02-22
- 7.0.2 — 2021-11-01
- 7.0.1 — 2021-10-08
- 7.0.0 — 2021-09-30
- 6.0.8 — 2021-06-14
- 6.0.7 — 2021-05-14
- 6.0.6 — 2021-03-13
- 6.0.5 — 2021-02-11
- 6.0.4 — 2020-12-18
- 6.0.3 — 2020-11-04
- 6.0.2 — 2020-08-13
- 6.0.1 — 2020-08-12
- 6.0.0 — 2020-07-03
- 5.0.10 — 2020-07-02
- 5.0.9 — 2020-05-25
- … 24 more at https://npm.io/package/@zestia/position-utils/versions

## README

# @zestia/position-utils

Utils for determining the position of an element within another element, and positioning
elements near other elements. Note that 'auto' positioning is intentionally not part of this library.

## getPosition

Returns where `element` is considered to be positioned inside `container`, based on a bounding box created by splitting the `container` into `columns` and `rows`.

<img src="docs/position.png" width="865" height="205">

### Examples

```javascript
// Get position of element inside container, could be in 1 of 9 possible positions
getPosition(element, container, 3, 3);
```

```javascript
// As above, but with edge positions less likely to be considered
getPosition(element, container, 5, 5);
```

## getCoords

Returns the coordinates required to place `element` at `position`, on the outside edge of `reference`.

<img src="docs/coords.png" width="288" height="288">

### Example

```javascript
// Get coords to position element at the bottom left of reference
getCoords('bottom left', element, reference);
```

---
_Source: https://npm.io/package/@zestia/position-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
