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

fantasma.js

v0.4.2

Published

A sophisticated animation library for the web

Downloads

6

Readme

:ghost: fantasma.js v0.4.2 'YAOGUI'

Version Series License Maintenance NPM

fantasma.js is a sophisticated animation library for the web. fantasma animates multiple elements in parallel, and supports multiple animation segments per element. It supports easings on a per-animation and per-segment basis. Animations are reusable; after being created, they must be supplied with an appropriate set of elements to produce a Playback object, which will animate those specific elements. Additionally, fantasma allows animation of any element property, not just CSS values.

Usage

const { Animation } = require("fantasma.js")

// Create a new animation for two elements. One elements width will be
// animated, the other's height will be animated. Each element has four
// animation segments and the entire animation will last four seconds.
const animation = new Animation({
  easing: "easeOutQuad",
  strips: [
    { obj: "left", prop: ["style", "width"], unit: "px", path: [
      {from: 0, to: 100, time: 1000},
      {to: 50, time: 1000},
      {to: 100, time: 1000},
      {to: 0, time: 1000},
    ]},
    { obj: "right", prop: ["style", "height"], unit: "px", path: [
      {from: 100, to: 50, time: 1000},
      {to: 0, time: 1000},
      {to: 50, time: 1000},
      {to: 100, time: 1000},
    ]},
  ],
})

// Get the elements to be animated. They must be stored in an object with
// property names matching those give for each element in the animation
// defintiion.
const els = {
  left: document.getElementById("left"),
  right: document.getElementById("right"),
}

// Get a Playback object from the animation. Here we supply the elements to be
// animated plus various playback options, such as looping. This way a single
// animation can be resused for multiple sets of elements, which different
// playback settings.
// `loop: -1` means our animation will loop forever.
const player = animation.player({els, loop: -1})

// Finally, play our animation:
player.play()

Options

Animation

Synopsis:

new Animation({
  easing: "linear", scale: 1,
  strips: [ ... ]
})
  • easing: One of the available easings. Affects the entire animation.
  • scale: Time scale. All animation timings are scaled by this factor.
  • strips: Animation Strips, explained below. One for each element.

Strips

Synopsis:

{ obj: "elem1", prop: ["style", "left"], unit: "px",
  easing: "easeInQuad", start: 100, 
  path: [ ... ]
}
  • obj: The name of the element to be animated. A real element is given later when a Playback object is created.
  • prop: The property of the object to be animated by this Strip. These are JS properties of the given element, not just CSS properties. An array of property names can be given to access nested objects.
  • unit: By default this is null, and fantasma will animate the given property with raw numeric values. If a unit is given, the values will be set on the property as strings with the given unit affixed. This is useful for animating CSS values.
  • easing: One of the available easings. Affects all segments of this strip.
  • start: The time at which this strip should begin, after the overall animation begins. Defaults to 0.
  • scale: Time scale. All segment timings are scaled by this factor.
  • path: An array of animation Segments, described below.

Segments

Synopsis:

{ from: 0, to: 100, time: 500, easing: "easeOutSine", scale: 2 },
# Or:
{ from: 0, to: 100, speed: 200 },
  • from: The starting value for this segment. If this is not given it will be inferred from the previous segment, or the properties initial value.
  • to: The end value of this segment.
  • time: The duration of this segment, in milliseconds.
  • easing: One of the available easings.
  • scale: Segment duration will be scaled by this factor.
  • speed: Specify the animation rate per second. If given, this will override time.

Playback

Synopsis:

const animation = new Animation( ... )
const player = animation.player({
  loop: -1,
  els: { ... }
})
player.play()
  • loop: Number of loops. A value of -1 means loop forever. The default value of 0 will play once then stop.
  • reverse: Play the animation in reverse.
  • bounce: Play in reverse every other loop.

Lifecycle options

These options all take a callback function. All will be called with the Playback object itself as their first and only argument.

  • before: Called before the entire animation begins.
  • after: Called after the entire animation ends.
  • beforeSkip: Called before a skip.
  • afterSkip: Called after a skip.
  • beforePause: Called before a pause.
  • afterPause: Called after a pause.
  • afterLoop: Called after each loop.
  • eachFrame: Called every animation frame.

License

Copyright 2020-2024 0E9B061F Available under the terms of the MIT LIcense.