raf-tweener

3.0.4 • Public • Published

raf-tweener

unstable

An extremely minimal tweening engine based on GSAP, powered by requestAnimationFrame.

var rafTweener = require('raf-tweener');
var eases = require('eases');
var target = {
    x: 0,
    y: 0
};

rafTweener.start();

rafTweener.to(
    target, //tween target object
    10, //duration
    {
        x: 100, //value to tween
        y: 50, //value to tween
        ease: eases.expoInOut, //an easing method takes in a value 0..1 and returns a value 0..1
        onUpdate: function() {
            console.log(this.x.toFixed(2), this.y.toFixed(2));
        },
        onUpdateScope: target,
        onComplete: function() {
            console.log('done!');
        }
    }
);

Usage

NPM

License

MIT, see LICENSE.md for details.

Readme

Keywords

Package Sidebar

Install

npm i raf-tweener

Weekly Downloads

1

Version

3.0.4

License

MIT

Last publish

Collaborators

  • bunnybones1