yzk-tween
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

Tween

npm-version npm-size npm-download

Intro

Simple、Lightful、Efficient tween interpolate library. less than 2kb.

Quick Start

install

npm install yzk-tween

usage example

import { Tween } from 'yzk-tween';

const params = {
    // startValue of tween.
    start: 0,
    // endValue of tween.
    end: 100,
    // the length of time that a tween takes to complete one cycle.
    duration: 3000,
    // repeat the tween repeat forever.
    infinite: true,
    // interpolate direction when repeat a tween.
    alternate: true,
    // how a tween progresses through the duration of each cycle.
    timing: v => {
      return v * v;
    },
    // get value of tween at current time.
    onUpdate: v => {
        console.log(v);
    },
    // a tween completed.
    onComplete: () => {
        console.log('mission completed');
    }
}

let t = new Tween(params);
t.start();

// stop this tween.
t.stop();

// reuse tween instance.
t.reset(params);

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.7
    1
    • latest

Version History

Package Sidebar

Install

npm i yzk-tween

Weekly Downloads

1

Version

1.0.7

License

MIT

Unpacked Size

16.1 kB

Total Files

10

Last publish

Collaborators

  • yuanzk