KeyframeKit

KeyframeKit

About

While working with the Web animation APII was surprised that there wasn’t an easy way to import animation keyframes directly from your CSS. You had to redefine them in JS, with a completely different format. That’s why I wrote a typed-to-spec library that you can convert from one to the other, so you can play your CSS-defined animations directly in JS. Along the way I’ve also added some other useful tools for working with the API.

Installation

Usage

Play CSS-defined animations with JS

In your CSS:

Then in JS:

The main reason to play your animation with JS is because you get much more control over its playback:

…and more.

Import animations directly from a CSS file

Instead of pulling an animation from the document’s stylesheets, you can also import it directly from a CSS file.

Note: This doesn’t solve anything @import rules in the style sheet. See here.

Defining animations in JS

The KeyframeEffectParameters class provides a more convenient way to define your animations in JS than is offered by default.
This is useful if you want to have all your animation code in one place.

Full reference

See here.

Typing

This library is fully compatible with native JS, but also provides full support for compliant types, including declaration files and source maps.

License

OF

#KeyframeKit

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *