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

animatum

v0.3.0

Published

A JavaScript library for animating elements between states

Downloads

356

Readme

A JavaScript library for animating elements between states

Based on animation code of SortableJS

Getting Staterd

Install:

$ npm install --save animatum

Import:

import Animatum from 'animatum';

Usage

import Animatum from 'animatum';

let container = document.getElementById('container');
let animatum = new Animatum(container);

// Save the "before state"
animatum.captureAllStates();

// Reverse the order of the elements
container.append(...Array.from(container.childNodes).reverse());

// Animate from the "before state" to the new state
animatum.animateAll();

API

new Animatum(container: HTMLElement[]|HTMLElement, options: Object): Animatum To use Animatum you must first create an instance of Animatum on the container(s) whose children you want to animate. An optional options object object may also be passed to set the global options.

animatum.captureAllStates(options: Object) Used to capture the animation states of all the children of the container(s). This should be done immediatly before the DOM change that you want to animate takes place. An optional options object object may be passed to overwrite the global options.

animatum.animateAll(options: Object) Used to animate from the captured animation states of all the children in the container(s) to their new state. This should be done after the DOM changes you want to animate have taken place. An optional options object object may be passed to overwrite the global options.

animatum.addState(state: AnimationState) Used to add a custom animation state to the captured animation states. If there is an already a state captured for the element, this added state will overwrite it. Refer to the AnimationState definition.

animatum.removeState(element: HTMLElement) Used to remove an animation state of the specified element from the captured animation states.

Options

duration {Number} The duration, in milliseconds, of the animation. Default: 150

easing {String} A string specifying the easing that should be applied to the animation. See easings.net for examples. Default: "ease"

ignore {Function|String} Function or CSS selector of element(s) that should be ignored during this action or all actions. If set to a function, the first argument will be the element, and returning true will make the element be ignored. Default: function() { return false; }

AnimationState

An AnimationState is an object specification that Animatum uses to track the captured animation states of elements. In order to add an animation state using the addState method, the object you pass in must contain the following properties.

element {HTMLElement} The element that this state is for

rect {DOMRect} The DOMRect (or object with DOMRect properties) of the element, that will serve as the captured position of the element.