Skip to content

francisrstokes/primer-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

primer-js

primer-js is a tiny (474 bytes minified + gzipped) library for creating normalised, unit independent timelines, for use in programatic animation.

API

See docs.

Example

const {timeline, timelineEvent} = require('primer-js');

const tl = timeline([
  // event "a" has a duration of 100 time units
  timelineEvent("a", { duration: 100 }),

  // event "b" lasts for 300 time units, but is delayed by 200
  timelineEvent("b", { duration: 300, preWait: 200 }),

  // event "c" lasts for 200 time units, and uses a custom expoential easing function
  timelineEvent("c", { duration: 200, ease: t => t**2 }),
]);

// Begin the timeline at t=0
tl.init(0);

// draw function is called with a a time in milleseconds as often as possible
const draw = t => {
  tl.update(t);

  // The values the timeline produces are always normalised to the inclusive range [0, 1]
  const someOpacityValue = tl.get("b").value();
};

About

🕰 A tiny (474 bytes minified + gzipped) library for creating normalised, unit independent timelines

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published