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

@avatijs/animation

v0.2.0

Published

Animation package part of Avati project

Readme

TypeScript Tweening Library

A lightweight and flexible tweening library for TypeScript that supports various data types and easing functions. This library provides smooth animations between values with customizable easing functions and supports numbers, colors, 2D vectors, and arrays.

Features

  • 🎯 Strong TypeScript support with type safety
  • 🎨 Multiple data type support:
    • Numbers
    • Colors (hex format)
    • 2D Vectors
    • Arrays of numbers
  • 🌊 Built-in easing functions:
    • Linear
    • Cubic (In/Out/InOut)
    • Quadratic (In/Out/InOut)
    • Elastic
    • Bounce
  • ⚡ Efficient animation management with RequestAnimationFrame
  • 🎮 Simple and intuitive API

Installation

npm install @avatijs/animation
# or
yarn add @avatijs/animation

Usage

Basic Example

import { Tween } from '@avatijs/animation';

// Animate a number from 0 to 100
const numberTween = new Tween({
    from: 0,
    to: 100,
    duration: 1000, // milliseconds
    onUpdate: (value) => {
        console.log('Current value:', value);
    },
    onComplete: () => {
        console.log('Animation completed!');
    }
});

numberTween.start();

Animating Different Types

Color Animation

const colorTween = new Tween({
    from: '#ff0000',
    to: '#0000ff',
    duration: 2000,
    easing: Tween.EasingFunctions.easeInOutCubic,
    onUpdate: (color) => {
        element.style.backgroundColor = color;
    }
});

2D Vector Animation

const vectorTween = new Tween({
    from: { x: 0, y: 0 },
    to: { x: 100, y: 200 },
    duration: 1500,
    onUpdate: (position) => {
        element.style.transform = `translate(${position.x}px, ${position.y}px)`;
    }
});

Array Animation

const arrayTween = new Tween({
    from: [0, 0, 0],
    to: [100, 200, 300],
    duration: 1000,
    onUpdate: ([x, y, z]) => {
        element.style.transform = `translate3d(${x}px, ${y}px, ${z}px)`;
    }
});

Using Different Easing Functions

// Available easing functions
const easings = Tween.EasingFunctions;
// - linear
// - easeInCubic
// - easeOutCubic
// - easeInOutCubic
// - easeInQuad
// - easeOutQuad
// - easeInOutQuad
// - easeInElastic
// - bounce

const tween = new Tween({
    from: 0,
    to: 100,
    duration: 1000,
    easing: Tween.EasingFunctions.bounce,
    onUpdate: (value) => {
        // Update logic
    }
});

Best Practices

  1. Cleanup: Always stop tweens when they're no longer needed, especially when removing elements:
// Stop the tween
tween.stop();
  1. Error Handling: Wrap tween creation in try-catch blocks when dealing with user input:
try {
    const tween = new Tween({...});
    tween.start();
} catch (error) {
    console.error('Invalid tween configuration:', error);
}
  1. Performance:
    • Avoid creating many simultaneous tweens
    • Use appropriate duration values (typically 200-2000ms)
    • Consider using requestAnimationFrame for smooth animations (built-in)

Common Pitfalls to Avoid

  • ❌ Don't create tweens in rapid succession without cleaning up old ones
  • ❌ Don't use extremely short durations (<100ms) as they may appear jerky
  • ❌ Don't forget to handle the cleanup when the component/element is destroyed
  • ❌ Don't use heavy computations in onUpdate callbacks
  • ❌ Don't create infinitely running tweens without a way to stop them

Advanced Usage

Chaining Tweens

const tween1 = new Tween({
    from: 0,
    to: 100,
    duration: 1000,
    onUpdate: (value) => {
        // First animation
    },
    onComplete: () => {
        // Start the next tween when this one completes
        tween2.start();
    }
});

const tween2 = new Tween({
    from: 100,
    to: 0,
    duration: 1000,
    onUpdate: (value) => {
        // Second animation
    }
});

// Start the chain
tween1.start();

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

I welcome contributions from developers of all experience levels. If you have an idea, found a bug, or want to improve something, I encourage you to get involved!

How to Contribute

  1. Read Contributing Guide for details on how to get started.
  2. Fork the repository and make your changes.
  3. Submit a pull request, and we’ll review it as soon as possible.

License

MIT License

Avati is open-source and distributed under the MIT License.


Follow on Twitter Follow on LinkedIn Follow on Medium Made with ❤️ Star on GitHub Follow on GitHub