Giter VIP home page Giter VIP logo

timeline.js's Introduction

Timeline.js

A compact JavaScript animation library with a GUI timeline for fast editing.

Check it out in this example: http://vorg.github.com/timeline.js/examples/cssAnimation.html

More on the project website: http://marcinignac.com/blog/timeline-js/

Created by Marcin Ignac

Timeline

Usage:

1. Animation

<script type="text/javascript" src="timeline/timeline.js"></script>

anim(target).to(delay, {property:value,...}, duration, easing);

After specifying the target using anim() you can chain as many to() animations as you want. To start parallel track simply call anim() on the same target again.

1.1 Basic example

Animate x property of the sprite object to 100 over 1s using quadratic easing. Then wait 5s and animate it back to 0 over 2s

anim(sprite).to({x:100}, 1, Timeline.Easing.Quadratic.EaseIn).to(5, {x:0}, 2);

1.2 Example of parallel animations

Animate width and height of the rect object to 50 and 75 over 3s. At the same time animate opacity to 0 over 4s.

anim(rect).to({width:50, height:75}, 3);
anim(rect).to({opacity:0}, 4);

2. Timeline GUI

<script type="text/javascript" src="timeline/gui.js"></script>

anim(targetName, target).to(delay, {property:value,...}, duration, easing);

Adding gui.js script to the page will open a timeline panel on the bottom of the page if any animation was added before first frame. One track for every animated property will be created. Click and drag to edit key frames, double click to add new frames. Press export button (tree horizontal lines) to export code you can then copy paste in your scrip .

In this case we have to specify targetName in anim() that will be used when we export the code from the timeline GUI. For each property used in to() call there will be an animation track created. Animation data is stored in localStorage and shared between sessions so refreshing the page and adding new properties and objects to be animated is possible. When an animation track exists in localStorage all to() calls modifying this property are ignored.

2.1 Example

anim("rect", rect).to({x:rect.x, y:rect.y});

Add the rect object and it's x and y properties to animation and use their default values. Target name should be always exactly the same as variable name.

3. Node.js

First install the timeline-js package from npm

npm install timeline-js

And then

var timeline = require('timeline-js');
var Timeline = timeline.Timeline;
var anim = timeline.anim;

anim(target).to(delay, {property:value,...}, duration, easing);

timeline.js's People

Contributors

vorg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.