Take control of your CSS keyframe animations
Health
Availability
Activity
Conventions and standards
jogwheel gives you the power to take full control of your CSS keyframe animations via JavaScript.
- separation of concerns: Declare animations with CSS
- full control: Play, pause and scrub your animations
- animation sequences: No brittle fiddling with animationEnd
- world peace
jogwheel is available on npm.
npm install --save jogwheel
Element.prototype.animate
is defined and returns a valid WebAnimationPlayer instance.
To achieve this you will have to include a WebAnimation polyfill, web-animations-js by Google is recommended.
The usage examples show recommended ways to include the polyfill.
jogwheel exposes its API as CommonJS module. Using the export and bundling your JavaScript with browserify, webpack or rollup is recommended.
// import the polyfill
import 'web-animations-js';
// import JogWheel
import JogWheel from 'jogwheel';
// Select target element
const element = document.querySelector('[data-animated]');
// Construct JogWheel instance from element
const player = JogWheel.create(element);
// Jump halfway into the animation
player.seek(0.5);
jogwheel provides prebundled downloads via brcdn.org.
Either embed or download the standalone bundle. Given you do not use a module system the standalone build will pollute window.jogwheel
. This usage is viable but not recommended.
<!doctype html>
<html>
<head>
<title>CDN example</title>
</head>
<style>
@keframes bounce {
0% {
transform: none;
}
25% {
transform: translateY(-100%);
}
50% {
transform: none;
}
75% {
transform: translateY(100%);
}
100% {
transform: none;
}
}
[data-animated] {
animation: bounce 1s;
animation-fill-mode: both;
animation-play-state: paused;
height: 100px;
width: 100px;
background: #333;
border-radius: 50%;
}
</style>
<body>
<div data-animated></div>
<script src="https://www.brcdn.org/web-animations-js/latest/?standalone=web-animations-js&uglify=true" />
<script src="https://www.brcdn.org/jogwheel/latest/?standalone=jogwheel&uglify=true" />
<script>
var element = document.querySelector('[data-animated]');
var player = JogWheel.create(element);
player.seek(0.5).play();
</script>
</body>
</html>
See API Documentation for details.
jogwheel shines brightest when used with CSS animations.
JavaScript
import JogWheel from 'jogwheel';
const element = document.querySelector('[data-animated]');
const player = JogWheel.create(element);
// Jump halfway into the animation
player.seek(0.5);
CSS
@keframes bounce {
0% {
transform: none;
}
25% {
transform: translateY(-100%);
}
50% {
transform: none;
}
75% {
transform: translateY(100%);
}
100% {
transform: none;
}
}
[data-animated] {
animation: bounce 1s;
/* animation-fill-mode and animation-play-state are recommended */
animation-fill-mode: both;
animation-play-state: paused;
height: 100px;
width: 100px;
background: #333;
border-radius: 50%;
}
HTML
<div data-animated>
</div>
See Examples for more use cases.
jogwheel performs cross browser testing with SauceLabs
You dig jogwheel and want to submit a pull request? Awesome! Be sure to read the contribution guide and you should be good to go. Here are some notes to get you coding real quick.
Fetch, install and start the default watch task
git clone https://github.com/marionebl/jogwheel.git
cd jogwheel
npm install
npm start
This will watch all files in source
and start the appropriate tasks when changes are detected.
jogwheel is up to a lot of good. This includes but is not limited to
- super-awesome cross-browser tests
- unit-tested documentation code examples, because rust isn't the only language that can do cool dev convenience stuff
- an interactive playground and animation editor
- a plug-an-play react integration component
See Roadmap for details.
jogwheel v1.3.0
is built by Mario Nebl and contributors with ❤️
and released under the MIT License.