0.5.0 • Published 4 years ago

@disorrder/timeline v0.5.0

Weekly downloads
2
License
-
Repository
-
Last release
4 years ago

timeline-js (was renamed from animated-js)

Timeline for simple animations. Inspired by @animejs.
I'm using it in my WebVR projects with Three.js or Playcanvas engine.
Please report all issues or ideas you will find ;)

Installation

Using npm:

npm i --save @disorrder/timeline --only=production

Yeah, all good names was busy :(

Basic usage

var target = {
    position: {x: 1, y: 2, z: 3}
};
var anim = new Timeline()
.add({
    repeat: 1,
    delay: 0,
    duration: 1000,
    animate: [{
        target: target.position,
        to: {x: 10}
    }],
    begin(frame) { /* ... */ },
    run(frame) { /* ... */ },
    complete(frame) { /* ... */ },
})
.play();

Timeline methods

add(frame)
play()
pause()
stop()
replay()

Keyframe type

repeat default: 1 -
delay default: 0 -
duration default: 1000 -
Animatable[] animate - Array of Animatables

preCalculate(frame) -
begin(frame) -
run(frame) -
complete(frame) -

Animatable type

Object``Function target - target of animation
Object from - start params
Object to - end params
Object by - if you want to translate some params by value
Function setter(target) - call every frame of animation with target in first argument

One more example

This code animates position.x from 10 to 20 and position.y from initial to initial+30.
So, if initial y is 100 it will be animated from 100 to 130.

var entity = new pc.Entity(); // new THREE.Object3D() for Three.js
var position = entity.getLocalPosition(); // imagine you don't know values of x, y and z
var anim = new Timeline()
.add({
    animate: [{
        target: position,
        from: {x: 10},
        to: {x: 20},
        by: {y: 30},
    }],
})
.play();
0.5.0

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

5 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago