npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

storyline.js

v1.4.1

Published

javascript animation sequencer

Downloads

3

Readme

Storyline.js - JavaScript Animation Sequencer

Storyline.js is a library to help define a storyboard using natural language.

Check all the demos

How to?

The Storyline class only come with two options :

  • storyboard: a simple object containing all keyframes.
  • timescale: (optional) multiply all key's time with it.
    var storyline = new Storyline(storyboard [, timescale]);

Storyboard hierarchy

  • name: the name of the animation.
  • time: the begining of the current value to the next one in milliseconds.
  • easing: the easing to use.
  • value: the value(s) to animate (multiple values are between parenthesis).
    {
        {name}: [
            "{time} {easing} to {value}",
            "{time} {easing} to {value}",
            "{time} {easing} to {value}"
        ],
        {name}: [
            "{time} {easing} to ({value}, {value}, {value})",
            "{time} {easing} to ({value}, {value}, {value})"
        ]
    }

Timing

Each key times are in milliseconds.

    var storyline = new Storyline({
        key1: [
            "0 cut to 0",
            "500 linear to 1",
            "1000 linear to 2"
        ]
    });

You may need to create animations with a limited duration, you can use the timescale option to do that. Each time will be multiplied by the timescale.


    var duration = 5000; // timescale of 5s

    var storyline = new Storyline({
        key1: [
            "0 cut to 0",
            "0.3 linear to 3",
            "1 linear to 4"
        ]
    }, duration);

Easing

There is already some basic easings:

  • cut: immediately switch to the value if the time is upper or equal to the key.
  • linear: linearly interpolate to the value.
  • easeIn: ease in from the previous value to the key value.
  • easeOut: ease out from the previous value to the key value.
  • easeInOut: ease in and out from the previous value to the key value.
  • easeInElastic: ease in elastic from the previous value to the key value.
  • easeOutElastic: ease out elastic from the previous value to the key value.
  • easeInOutElastic: ease in and out elastic from the previous value to the key value.
  • easeInBounce: ease in bounce from the previous value to the key value.
  • easeOutBounce: ease out bounce from the previous value to the key value.
  • easeInOutBounce: ease in and out bounce from the previous value to the key value.
  • quadratic(from,c,to): get value along a qaudratic bezier curve (see stackoverflow explainations).
  • cubic(from,cx,cy,to): get value along a cubic bezier curve (see stackoverflow explainations).

But you can also register your own easings:

    Storyline.registerEasing(customEasingName, function( elapsed, duration, options ){

        return (elapsed / duration); // Linear easing

    });
  • elpsed: normalized elpased time (between 0 and 1).
  • duration: normalized duration (always 1...)
  • options: array of values, only if the easing take options (parenthesis with parameters).

Type

You can animate one or many values in each keys but you can also use types:

  • int: only returns integers.
  • bool: return true if the value is upper or equal to 1, else return false.
  • vec2: return the values with .x and .y getters.
  • vec3: return the values with .x, .y and .z getters.
  • color: return the values with .r, .g, .b, hex and hexString getters.

But you can also register your own types:

Storyline.registerType(name, getter, setter)

    Storyline.registerType("invert", function( options, originOptions ){

        for( var option = 0, length = options.length; option < length; option++ ){

            options[option] *= -1;

        };

        return options;

    }, function( options, originString ){

        return options;

    });

Examples

Simple

   var storyline = new Storyline({
    key1: [
        "0 cut to 0",
        "500 easeIn to 360",
        "1000 linear to 180"
    ],
    key2: [
        "500 cut to 180",
        "1000 lienar to 0"
    ]
   });

   function update( now ){

       window.requestAnimationFrame(update);

       var key1 = storyline.get("key1", now);
       var key2 = storyline.get("key2", now);

   };

   window.requestAnimationFrame(update);

With fixed duration

   var storyline = new Storyline({
    key1: [
        "0 cut to 0",
        "0.5 easeIn to 360",
        "1 linear to 180"
    ],
    key2: [
        "0.5 cut to 180",
        "1 lienar to 0"
    ]
   }, 1000);

   function update( now ){

       window.requestAnimationFrame(update);

       var key1 = storyline.get("key1", now);
       var key2 = storyline.get("key2", now);

   };

   window.requestAnimationFrame(update);

Check all the demos/examples

License

MIT licensed

Original idea from Jaume Sanchez Elias Entirely rewrited by Jordan Delcros