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

nanotween

v0.8.0

Published

Tiny library for tweening

Downloads

918

Readme

NanoTween

~1.5 KB is quite enough for full-featured and comfortable tweening
image

Is it small enough?

I made some researches with bundlephobia and size-limit and here's what I can say

For now, NanoTween core is the smallest tweening core on NPM

library    ¦ size
-----------¦-------
gsap       ¦ 37.0 KB
moofx      ¦  7.4 KB
es6-tween  ¦  6.0 KB
animejs    ¦  5.7 KB
kute       ¦  5.6 KB
tweenr     ¦  4.7 KB
shifty     ¦  4.2 KB
kute       ¦  3.4 KB
tweenjs    ¦  2.9 KB
tweeno     ¦  2.8 KB
anim       ¦  1.1 KB
nanotween  ¦  0.8 KB

Included features

  • Easing functions
  • Tweening delays
  • Chaining and groupping
  • Yo-yo effect
  • You can start/stop, play/pause, reverse on-fly or force set tweening progress
  • Also has IIFE build to include as <script> file

Advantages

  • Ultra small size (only <1KB core, 1.5KB with all helpers, <2.5KB with all easings)
  • Low-level API lets you easily adapt it to your needs
  • Big list of ready-to-use easing functions
  • Easings and helpers are separated from core library so you can add only needed functions

Installation

From NPM

npm install nanotween
yarn add nanotween

From unpckg

<script src="https://unpkg.com/[email protected]/dist/index.js"></script>
<script src="https://unpkg.com/[email protected]/dist/helpers.js"></script>
<script src="https://unpkg.com/[email protected]/dist/easings.js"></script>

NanoTween is available as is. Helpers are available in ntHelpers global variable, easings - in ntEasings.
If you don't need helpers or easings, you can include only core script.

Complete guide

You can find complete guide and live demos on wiki

Countdown example

Simple countdown timer

import NanoTween from 'nanotween'
import { linear } from 'nanotween/easings'

// Start tweening process
const animate = time => {
  requestAnimationFrame(animate)
  NanoTween.update(time)
}
animate(performance.now())

// Duration in seconds
const duration = 10

// Element
const el = document.getElementById('tween')

// Create tween object
const tween = new NanoTween()
  .duration(duration * 1000)
  .repeat(3)
  .easing(linear)
  .on('update', progress => {
    el.innerHTML = (progress * duration).toFixed(2)
  })
  .on('complete', () => alert('Time is over'))

// Start timer
tween.start()

image

License

MIT