# css-animation-sync

> Synchronise and control CSS Animations

Latest version **0.5.0** (published 2021-11-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install css-animation-sync
pnpm add css-animation-sync
yarn add css-animation-sync
bun add css-animation-sync
```

## 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.5.0 |
| Published | 2021-11-19 |
| First published | 2017-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52 |
| Author | David Beale |
| Maintainers | bealearts |
| Keywords | css, animation, sync, spinners |

## Links

- npm: https://www.npmjs.com/package/css-animation-sync
- Repository: https://github.com/bealearts/css-animation-sync
- Homepage: https://github.com/bealearts/css-animation-sync#readme
- Issues: https://github.com/bealearts/css-animation-sync/issues
- npm.io page: https://npm.io/package/css-animation-sync

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 0.5.0 (latest) — 2021-11-19
- 0.4.0-beta-2 (next) — 2021-08-04
- 0.4.1 — 2021-08-23
- 0.4.0 — 2021-08-06
- 0.4.0-beta-1 — 2021-08-02
- 0.3.0 — 2021-06-28
- 0.2.0 — 2020-04-07
- 0.1.1 — 2020-01-28
- 0.0.7 — 2019-06-10
- 0.0.6 — 2017-11-08
- 0.0.5 — 2017-09-26
- 0.0.3 — 2017-09-24
- 0.0.2 — 2017-09-23
- 0.0.1 — 2017-09-23
- 0.0.0 — 2017-09-23

## README

# css-animation-sync [![Build Status](https://travis-ci.org/bealearts/css-animation-sync.png?branch=master)](https://travis-ci.org/bealearts/css-animation-sync) [![npm version](https://badge.fury.io/js/css-animation-sync.svg)](http://badge.fury.io/js/css-animation-sync) [![Dependency Status](https://david-dm.org/bealearts/css-animation-sync.png)](https://david-dm.org/bealearts/css-animation-sync)

Synchronise and control CSS Animations

> NOTE: This library was created before the availability of the [Web Animations API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API) and this may now provide a better solution for you.

# The Problem

When DOM elements styled with the same CCS Animation are added to the document at different times, the animations are out of synchronisation.

|Problem|Solution|
|-------|--------|
|Elements added at different times are out of sync|Adding `sync('spinner');`|
|![Before](./docs/before.gif)|![After](./docs/after.gif)|

Interactive [Example](https://raw.githack.com/bealearts/css-animation-sync/master/example/index.html)

# Usage
```js
import sync from 'css-animation-sync';

sync('spinner');
```

# Install
```shell
npm install css-animation-sync --save
```

# API

* `const animation = new sync(animationName || animationNames)` - Synchronises all DOM elements using a CSS animation or multiple CSS animations. The animations duration needs to be the same for syncing to make sense.

    * `animationName` Name of the CSS animation to sync
    * `animationNames` Array of CSS animations to sync (allows syncing multiple animations)


    Returns an animation instance (see below)

* `animation.free()` - Stops synchronisation of DOM elements using the animation

* `animation.pause()` - Pause the animation of DOM elements using the animation

* `animation.stop()` - Stop the animation of DOM elements using the animation

* `animation.start()` - Start/Resume the animation of DOM elements using the animation


# Test
```shell
npm install
npm test
```

# Dev
```shell
npm start
```

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