# adjust-engine

> adjust an element relative to another element

Latest version **2.0.4** (published 2015-08-31) · 0 weekly downloads

## Install

```sh
npm install adjust-engine
pnpm add adjust-engine
yarn add adjust-engine
bun add adjust-engine
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2015-08-31 |
| First published | 2015-08-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Matthew Mueller |
| Maintainers | mattmueller |
| Keywords | adjust, position |

## Links

- npm: https://www.npmjs.com/package/adjust-engine
- Repository: https://github.com/MatthewMueller/adjust-engine
- Issues: https://github.com/MatthewMueller/adjust-engine/issues
- npm.io page: https://npm.io/package/adjust-engine

## Dependencies (1)

- [object-assign](https://npm.io/package/object-assign.md) ^3.0.0

## Recent versions

- 2.0.4 (latest) — 2015-08-31
- 2.0.3 — 2015-08-31
- 2.0.2 — 2015-08-31
- 2.0.1 — 2015-08-26
- 2.0.0 — 2015-08-24
- 1.0.1 — 2015-08-19
- 1.0.0 — 2015-08-19

## README

# adjust-engine

  Position an element relative to another element. This repository is the workhorse behind [adjust](https://github.com/matthewmueller/adjust).

## Installation

```
npm install adjust-engine
```

## API

##### `adjust = Adjust(options)`

Initialize an adjustment. Supports the following options:

- **attachment** (string): Alignment point of the element you're moving. Supports CSS style adjustments.
  Here are some possibilities:

```
left top
right bottom
center middle
10% 16% (x y)
```

- **target** (string): Alignment point of the target (or host) element. Supports same CSS style adjustments as `attachment`.

- **offset** (object): Specify an offset to apply to the attachment element:

```
x: 10
y: -10
```

- **flip** (boolean): Defaults to `true`. Automatically flip the element if the adjustment causes the attachment to be out of viewport. You should specify a `viewport_position` for flip to work properly.

##### `adjust(attachment_position, target_position, [ viewport_position ])`

Get a position of where the attachment should be. Here's a full example:

```js
var adjust = Adjust({
  attachment: 'center middle',
  target: 'center middle'
});

var attachment = {
  height: 50,
  width: 50
}

var target = {
  top: 0,
  left: 0,
  right: 100,
  bottom: 100
}

var position = adjust(attachment, target)
assert.deepEqual(position, {
  top: 25,
  left: 25,
  width: 50,
  height: 50,
  right: 75,
  bottom: 75
})
```

## Tests

```
make test
```

## TODO

- memoize

## License

MIT

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