@immutabl3/tween
v1.0.0
Published
trimmed down, modern version of sole/tween for tree shaking
Downloads
2
Readme
micro-tween
A trimmed down, modern version of sole's tween.js for treeshaking
npm i micro-tween
notable changes
Easing functions are located in micro-tween/ease
to be imported to save on file size. Polyfills for window.performance.now
have been removed in favor of Date.now
(keeping node support via process.hrtime).
Additional removals:
- no interpolation
- no string relative values
- no safety checks
- no
this
context in functions, use passed object - no constructor function/generated code
- no
getAll
/removeAll
tweens
Everything else should work!
Example
import tween, {
update,
elasticInOut
} from 'micro-tween';
tween({ x: 0 })
.to({ x: 100 })
.yoyo()
.repeat(2)
.ease(elasticInOut)
.onStart(function() {
console.log('start');
})
.onUpdate(function(value) {
console.log('value: ', value.x);
})
.onComplete(function() {
console.log('complete');
})
.start();
const tick = function() {
update();
requestAnimationFrame(tick);
};
tick();