# tail-end

> Promise-wrapped CSS animations and transitions (async/await friendly).

Latest version **0.3.0** (published 2018-12-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install tail-end
pnpm add tail-end
yarn add tail-end
bun add tail-end
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2018-12-28 |
| First published | 2017-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Michael Cavalea |
| Maintainers | callmecavs |

## Links

- npm: https://www.npmjs.com/package/tail-end
- Repository: https://github.com/callmecavs/tail-end
- Homepage: https://github.com/callmecavs/tail-end#readme
- Issues: https://github.com/callmecavs/tail-end/issues
- npm.io page: https://npm.io/package/tail-end

## Recent versions

- 0.3.0 (latest) — 2018-12-28
- 0.2.1 — 2018-08-06
- 0.2.0 — 2018-08-06
- 0.1.0 — 2017-09-11
- 0.0.1 — 2017-03-16

## README

# tail-end

[![tail-end on NPM](https://img.shields.io/npm/v/tail-end.svg?style=flat-square)](https://www.npmjs.com/package/tail-end) [![tail-end Downloads on NPM](https://img.shields.io/npm/dm/tail-end.svg?style=flat-square)](https://www.npmjs.com/package/tail-end) [![Standard JavaScript Style](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)

Promise-wrapped CSS animations and transitions (`async`/`await` friendly).

## Install

```sh
$ npm i tail-end --save
```

## API

The following functions are exported:

* `animationEnd(node[, function])`
* `transitionEnd(node[, function])`

Both exports add a Promise-wrapped event handler to the node. The Promise removes the event listener and resolves itself when the event is triggered.

```javascript
import { animationEnd } from 'tail-end'

// bind the event, then trigger it
animationEnd(node)
  .then(() => console.log('Transition ended.'))
  .catch(error => console.log('Invalid node passed in: ', error))

node.classList.add('will-animate')
```

For usage with `async`/`await` you can pass in a `function` as the second parameter. The function will be called in an [animation frame](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame) after the event listener is bound, and passed the `node`.

```javascript
import { transitionEnd } from 'tail-end'

// define a sequence of animations/transitions with async/await
const sequence = async () => {
  await transitionEnd(node, node => node.style.transform = 'translate3d(100px, 0, 0)')
  await transitionEnd(node, node => node.style.transform = 'translate3d(0, 0, 0)')
  await transitionEnd(node, node => node.style.transform = 'translate3d(-100px, 0, 0)')
}

// run the sequence
sequence().then(() => console.log('Sequence completed.'))
```

## License

[MIT](https://opensource.org/licenses/MIT). © 2018 Michael Cavalea

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