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

@daeinc/timeline

v0.5.2

Published

A wrapper class on top of keyframes package

Downloads

72

Readme

@daeinc/timeline

A Timeline object can hold multiple properties with keyframes. ex. position, rotation, color, etc., and makes it easy to group things together. In my own projects, I create multiple Timeline objects, one for each graphical object.

It builds on top of keyframes, but does not expose Keyframes library to user - user only needs to provide a minimum amount of necessary data. ex. { time, value, ... }

In development, and breaking changes are expected in the future.

Installation

npm i @daeinc/timeline

Then,

import Timeline from "@daeinc/timeline";

Examples

Pass a timeline name and a single property object ({name, keyframes}) or an array of property objects ([{name, keyframes}, {name, keyframes}]):

const tl = new Timeline("my-timeline", {
  name: "position",
  keyframes: [
    { time: 0, value: 5 },
    { time: 1, value: 10 },
  ],
});

const v1 = tl.value("position", 0.5); // returns 7.5

Pass a custom interpolator function:

JS:

const easeInQuad = (a, b, t) => {
  return lerp(a.value, b.value, t * t);
};

const v2 = tl.value("position", 0.5, easeInQuad);
console.log(v2); // 6.25

TS:

import type { Keyframe } from "@daeinc/timeline";

const easeInQuad = (a: Keyframe, b: Keyframe, t: number) => {
  return lerp(a.value, b.value, t * t);
};

const v2 = tl.value("position", 0.5, easeInQuad);
console.log(v2); // 6.25

Methods

constructor(propOrProps?: InputProp | InputProp[]);

propExists(propName: string): boolean;

addKeyframe(propName: string, newKey: Keyframe): void;

addKeyframes(propName: string, ...newKeys: Keyframe[]): void;

getKeyframe(propName: string, timeStamp: number): Keyframe;

getKeyframes(propName: string): Keyframe[];

getName(): string;

getPropertyNames(): string[];

value(propName: string, timeStamp: number, interpolator?: Interpolator): any;

addProperty(propName: string, ...newKeys: Keyframe[]): void;

removeKeyframes(propName: string, index: number, howmany: number): void;

nearest(propName: string, timeStamp: number, radius?: number): Keyframe;

nearestIndex(propName: string, timeStamp: number, radius?: number): number;

next(propName: string, timeStamp: number): Keyframe;

previous(propName: string, timeStamp: number): Keyframe;

static fromJSON(file: string): Promise<void | Timeline>;

static from(data: {
  name: string;
  properties: InputProp[];
}): Timeline;

toJSON(): string;

To Dos

  • add more examples
    • how to add keyframes
    • how to import and export
  • implement the rest of the methods from keyframes package
  • add a separate .d.ts for keyframes JS package, or, create a TS version of the keyframes package as a class.
  • throw errors or return null or guard against them?

License

MIT