Shifty

npm install --save shifty

DownloadSource

Shifty is a JavaScript tweening engine designed to fit all of your animation needs. Shifty's key benefits include:

If you're looking for a high-performance animation engine with low overhead, minimal memory footprint, and a permissive license (MIT), Shifty might be the right choice for you!

Shifty is a low-level animation solution. It does not perform any rendering, but it can be easily integrated into whatever rendering mechanism is most appropriate for your project. Shifty is meant to be a lightweight alternative to richer tools like the excellent GreenSock Animation Platform.

Shifty powers Stylie and Mantra, a suite of graphical animation tools. It is also the tweening engine used by GDevelop and ProgessBar.js. Even Yelp has used it!

Please use, fork, and contribute to Shifty! It is distributed under the MIT License, and experimentation is encouraged. If you find a bug or have a question about Shifty, please submit it via the Github issue tracker.

See the Pen Shifty async/await demo by Jeremy Kahn (@jeremyckahn) on CodePen.

Getting started with Shifty

Take a look at the Getting Started guide to hit the ground running. The most important class in Shifty is Tweenable, but you may also find Scene handy for controlling groups of tweens.

Demos

Sequencing

See the Pen Shifty Sequencing Demo by Jeremy Kahn (@jeremyckahn) on CodePen.

awaited tweens

See the Pen Primise-chained tweens by Jeremy Kahn (@jeremyckahn) on CodePen.

This next example demonstrates how awaited tweens interoperate well with standard JavaScript try/catch blocks, as well as infinite while loops. Typically you'd want to avoid intentionally infinite loops, but it's common to need animations to loop indefinitely. A while (true) loop is a simple way to achieve this. The ball in this demo pulsates repeatedly, but the animation loop is gracefully interrupted when the user clicks anywhere else within the demo. Response to the user's input is handled in catch blocks, wherein the ball swings over to where the user clicked. From there it continues to pulsate. With awaited tweens, you can have full control over the lifecycle of an animation with standard JavaScript programming constructs, rather than a library API that may or may not integrate well with other libraries.

See the Pen async/await try/catch demo by Jeremy Kahn (@jeremyckahn) on CodePen.

Tweening with a custom easing formula

See the Pen Tweening with a custom easing formula by Jeremy Kahn (@jeremyckahn) on CodePen.

Shifting a color

See the Pen Shifting a color by Jeremy Kahn (@jeremyckahn) on CodePen.

Tweening numbers within an arbitrary string

See the Pen Tweening numbers within an arbitrary string by Jeremy Kahn (@jeremyckahn) on CodePen.