@immutabl3/tween

1.0.0 • Public • Published

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();

Readme

Keywords

none

Package Sidebar

Install

npm i @immutabl3/tween

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

12.1 kB

Total Files

8

Last publish

Collaborators

  • immutabl3