# css-keyframe-animatable

> Convert CSS @keyframes like object to Element.animate compatible array

Latest version **1.0.0** (published 2016-09-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install css-keyframe-animatable
pnpm add css-keyframe-animatable
yarn add css-keyframe-animatable
bun add css-keyframe-animatable
```

## 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 | 1.0.0 |
| Published | 2016-09-06 |
| First published | 2016-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | inuscript |
| Maintainers | inuscript |
| Keywords | css, keyframe |

## Links

- npm: https://www.npmjs.com/package/css-keyframe-animatable
- Repository: https://github.com/inuscript/css-keyframe-animatable
- Homepage: https://github.com/inuscript/css-keyframe-animatable#readme
- Issues: https://github.com/inuscript/css-keyframe-animatable/issues
- npm.io page: https://npm.io/package/css-keyframe-animatable

## Dependencies (2)

- [key-replace](https://npm.io/package/key-replace.md) ^1.0.0
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.11.6

## 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

- 1.0.0 (latest) — 2016-09-06
- 0.0.2 — 2016-09-06

## README

# css-keyframe-to-array

Convert CSS `@keyframes` like object to `Element.animate` compatible array

[![npm](https://img.shields.io/npm/v/css-keyframe-animatable.svg)](https://www.npmjs.com/package/css-keyframe-animatable)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![Build Status](https://travis-ci.org/inuscript/css-keyframe-animatable.svg?branch=master)](https://travis-ci.org/inuscript/css-keyframe-animatable)

```js
const cssKeyframesToArray = require('css-keyframe-to-array')

const input = {
  from: { marginTop: '50px' },
  to: { marginTop: '100px' }
}

cssKeyframesToArray(input)
```

Output

```js
[
  { marginTop: '50px', offset: 0 },
  { marginTop: '100px', offset: 1 }
]
```

More complex example

```js
const input = {
  '0% ': { top: 0, left: 0 },
  '30%': { top: '50px', animationTimingFunction: 'ease-out' },
  '68%, 72%': { left: '50px' },
  '100%': { top: '100px', left: '100%' }
}
cssKeyframesToArray(input)
```

```js
[
  { top: 0, left: 0, offset: 0 },
  { top: '50px', offset: 0.3 , easing: 'ease-out'},
  { left: '50px', offset: 0.68 },
  { left: '50px', offset: 0.72 },
  { top: '100px', left: '100%', offset: 1 }
]
```
- Percentage timing is replace to `offset` (between 0.0 ~ 1.0)
- Flatten comma separated percentage timing
- `animationTimingFunction` or `animation-timing-function` is replaced to `easing`

# Related Project

- [keyshond](https://github.com/inuscript/keyshond)

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