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 🙏

© 2026 – Pkg Stats / Ryan Hefner

declarative-svg-animator

v1.0.1

Published

A small declarative SVG animation library (JS). Define animations with data attributes or JSON inside SVG.

Downloads

6

Readme

declarative-svg-animator

A small library for creating SVG animations declaratively using the data-animate attribute. Written in pure JavaScript (CommonJS) and lightweight, suitable for bundlers (Webpack/Rollup/Parcel) or Node-based builds.

Briefly:

  • Nama paket: declarative-svg-animator
  • Language: JavaScript (CommonJS)
  • Goal: declare animations in SVG elements with JSON in the data-animate attribute.

Feature

  • Declarative: define animations directly in SVG elements.
  • Interpolation of numeric values ​​(including units such as px, %).
  • Some basic easing (linear, easeInQuad, easeOutQuad, easeInOutQuad).
  • Timeline control: add, stop animation.
  • Simple API for integration and testing.

Installation

From npm (after publish):

npm install declarative-svg-animator

Or use the bundler to generate a browser bundle.

How to use (quick example)

Contoh SVG:

<svg width="400" height="120">
<rect id="r" x="10" y="10" width="50" height="50" fill="tomato"
data-animate='{"attribute":"x","to":250,"dur":1200,"easing":"easeInOutQuad"}' />
</svg>

Initialization in JS:

const lib = require('declarative-svg-animator'); // CommonJS
const animations = lib.parse(document);         // cari elemen [data-animate]
const tl = lib.createTimeline();                // create a timeline
animations.forEach(desc => tl.add(desc));      // run all found animations

If you want manual control for a single animation:

const a = new lib.Animator({
element: document.getElementById('r'),
attribute: 'x',
from: 10,
to: 200,
dur: 1000,
easing: 'easeInOutQuad'
});
const tl = lib.createTimeline();
tl.add(a);

Format atribut data-animate

The data-animate attribute contains short JSON. Supported fields:

  • attribute (string) — name of the attribute/style to be animated (e.g. "x", "y", "width", "fill").
  • to (number|string) — destination value.
  • from (number|string, optional) — initial value; if not set, the library reads the value at runtime.
  • dur (number, ms) — duration in milliseconds (default 1000).
  • delay (number, ms) — delay before starting.
  • easing (string) — "linear", "easeInQuad", "easeOutQuad", "easeInOutQuad".
  • iterations (number) — number of repetitions (default 1).
  • direction (string) — "normal" or "reverse".
  • id (string, optional) — id for reference.

Example:

<circle cx="20" cy="50" r="10" data-animate='{"attribute":"cx","to":300,"dur":1500,"delay":200}' />

Note: color interpolation and simple transform support is limited; use numeric values ​​or values ​​with the same units for best results.

API Reference

  • parse(root)

  • Description: looks for elements with data-animate at the root (Document or element) and returns an array of descriptors.

  • Contoh: const list = lib.parse(document);

  • createTimeline()

  • Description: creates a timeline that runs the animation. Returns an object with the method:

  • add(descriptor | Animator) -> Animator

  • stopAll()

  • isRunning()

  • Contoh: const tl = lib.createTimeline(); tl.add(desc);

  • Animator (class)

  • Konstruktor menerima descriptor { element, attribute, from?, to, dur?, delay?, easing?, iterations?, direction? }.

  • Metode: play(), pause(), tick(now), onfinish(fn).

Development & Build

  • Project structure:
  • index.js (entry)
  • package.json
  • src/ (animator, parser, timeline, utils)
  • To build the browser bundle, add the Rollup/webpack configuration and UMD/ESM build to the dist folder.
  • To publish to npm:
  1. Make sure package.json contains a unique name.
  2. Add README.md and LICENSE.
  3. Login npm: npm login
  4. Publish: npm publish --access public

Testing & Debug

  • The library is structured so that it can be tested with unit tests in the src/ module.
  • Run custom tests according to the test script in package.json (if any).

Contribution

  • Fork the repo, create a feature/bugfix branch, open a PR with a short description.
  • Preferences: add unit tests and short documentation for new features.

License

MIT — add the LICENSE file in the root of the repo before publishing.

Final note

The library focuses on simplicity. For advanced needs (morphs, complex colors, transform matrices), consider adding custom color parsers and interpolators.


# declarative-svg-animator

A small library for creating SVG animations declaratively using the `data-animate` attribute. Written in pure JavaScript (CommonJS) and lightweight, suitable for bundlers (Webpack/Rollup/Parcel) or Node-based builds.

Briefly:
- Nama paket: declarative-svg-animator
- Language: JavaScript (CommonJS)
- Goal: declare animations in SVG elements with JSON in the `data-animate` attribute.

## Feature
- Declarative: define animations directly in SVG elements.
- Interpolation of numeric values ​​(including units such as px, %).
- Some basic easing (linear, easeInQuad, easeOutQuad, easeInOutQuad).
- Timeline control: add, stop animation.
- Simple API for integration and testing.

## Installation
From npm (after publish):
```bash
npm install declarative-svg-animator

Or use the bundler to generate a browser bundle.

How to use (quick example)

Contoh SVG:

<svg width="400" height="120">
<rect id="r" x="10" y="10" width="50" height="50" fill="tomato"
data-animate='{"attribute":"x","to":250,"dur":1200,"easing":"easeInOutQuad"}' />
</svg>

Initialization in JS:

const lib = require('declarative-svg-animator'); // CommonJS
const animations = lib.parse(document);         // cari elemen [data-animate]
const tl = lib.createTimeline();                // create a timeline
animations.forEach(desc => tl.add(desc));      // run all found animations

If you want manual control for a single animation:

const a = new lib.Animator({
element: document.getElementById('r'),
attribute: 'x',
from: 10,
to: 200,
dur: 1000,
easing: 'easeInOutQuad'
});
const tl = lib.createTimeline();
tl.add(a);

Format atribut data-animate

The data-animate attribute contains short JSON. Supported fields:

  • attribute (string) — name of the attribute/style to be animated (e.g. "x", "y", "width", "fill").
  • to (number|string) — destination value.
  • from (number|string, optional) — initial value; if not set, the library reads the value at runtime.
  • dur (number, ms) — duration in milliseconds (default 1000).
  • delay (number, ms) — delay before starting.
  • easing (string) — "linear", "easeInQuad", "easeOutQuad", "easeInOutQuad".
  • iterations (number) — number of repetitions (default 1).
  • direction (string) — "normal" or "reverse".
  • id (string, optional) — id for reference.

Example:

<circle cx="20" cy="50" r="10" data-animate='{"attribute":"cx","to":300,"dur":1500,"delay":200}' />

Note: color interpolation and simple transform support is limited; use numeric values ​​or values ​​with the same units for best results.

API Reference

  • parse(root)

  • Description: looks for elements with data-animate at the root (Document or element) and returns an array of descriptors.

  • Contoh: const list = lib.parse(document);

  • createTimeline()

  • Description: creates a timeline that runs the animation. Returns an object with the method:

  • add(descriptor | Animator) -> Animator

  • stopAll()

  • isRunning()

  • Contoh: const tl = lib.createTimeline(); tl.add(desc);

  • Animator (class)

  • Konstruktor menerima descriptor { element, attribute, from?, to, dur?, delay?, easing?, iterations?, direction? }.

  • Metode: play(), pause(), tick(now), onfinish(fn).

Development & Build

  • Project structure:
  • index.js (entry)
  • package.json
  • src/ (animator, parser, timeline, utils)
  • To build the browser bundle, add the Rollup/webpack configuration and UMD/ESM build to the dist folder.
  • To publish to npm:
  1. Make sure package.json contains a unique name.
  2. Add README.md and LICENSE.
  3. Login npm: npm login
  4. Publish: npm publish --access public

Testing & Debug

  • The library is structured so that it can be tested with unit tests in the src/ module.
  • Run custom tests according to the test script in package.json (if any).

Contribution

  • Fork the repo, create a feature/bugfix branch, open a PR with a short description.
  • Preferences: add unit tests and short documentation for new features.

License

MIT — add the LICENSE file in the root of the repo before publishing.

Final note

The library focuses on simplicity. For advanced needs (morphs, complex colors, transform matrices), consider adding custom color parsers and interpolators.