Socket
Socket
Sign inDemoInstall

nanotween

Package Overview
Dependencies
2
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nanotween

Tiny library for tweening


Version published
Weekly downloads
156
decreased by-4.88%
Maintainers
1
Install size
35.9 kB
Created
Weekly downloads
 

Readme

Source

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 is the smallest tweening library on NPM

library    ¦ size
-----------¦-------
es6-tween  ¦ 6.0 KB
tweenr     ¦ 4.7 KB
shifty     ¦ 4.2 KB
tweenjs    ¦ 2.9 KB
tweeno     ¦ 2.8 KB
nanotween  ¦ 1.6 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

Advantages

  • Ultra small size (only <1.5KB core, 2KB with all helpers, <3KB 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

npm install nanotween
yarn add nanotween

Complete guide

You can find complete guide and more examples on Wiki page

Countdown example

Simple countdown timer

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

// Start tweening process
const animate = () => {
  requestAnimationFrame(animate)
  Nanotween.update()
}
animate()

// Some element and duration in seconds
const el = document.getElementById('tween')
const duration = 10

// 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

FAQs

Last updated on 10 Jan 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc