0.2.0 • Published 10 years ago

koijs v0.2.0

Weekly downloads
429
License
MIT
Repository
github
Last release
10 years ago

koi.js

Key Object Interpolation

NPM Version NPM Downloads

How to use

You can use this library in your browser and node application

Browser

Download the build/koi.js file and add it to your site

<script src="koi.js"></script>

Node

Run

npm install koi.js

and use it in you code

var koi = require('koi.js');

How to build src

npm install
npm run build

Run tests

npm test

Examples

Browser

HTML examples be found unter the examples folder (check the console maybe).

<script src="koi.js"></script>
<script>
  var animation = new koi.Animation({
    from: {x: 1, y: 0},
    to: {x: -1, y: 10}
  });
  animation.onStart(progress => console.log('start'));
  animation.onUpdate(progress => console.log(progress));
  animation.onStop(progress => console.log('stop'));
  animation.start();
</script>

Node

Because there is no autoupdate via requestAnimationFrame, you need to disable autoUpdate for node usage.

var koi = require('koi.js');

var animation = new koi.Animation({
  from: {x: 0},
  to: {x: 1},
  autoUpdate: false,
  animationTime: 1000 });

animation.onUpdate((interpolatedObject, progress) => {
  console.log(progress);
});

animation.start();

Remember to call update manually with

animation.updater.update(YOUR_DELTA_TIME_HERE);