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

phena

v2.1.1

Published

Petit animation engine

Downloads

9

Readme

phena

Build Status

🔮 Petit tweening engine based on requestAnimationFrame

The name of the library comes from the phenakistiscope discs, one of the first motion artifacts used for entertainment.

Install

Add it to your application using a package manager.

# npm
npm i phena --save

# yarn
yarn add phena

You can also drop it in the browser using a script with https://unpkg.com/phena as source.

Tween class

To start tweening a value import the Tween class first and pass the options.

import { Tween } from 'phena'

new Tween({ from: 1, to: 10, duration: 2000 })

This will iterate values from 1 to 10 in 2 seconds.

To react to this iteration define an onUpdate method.

import { Tween } from 'phena'

function onUpdate(value) { console.log(value) }

new Tween({ from: 1, to: 10, duration: 2000, onUpdate })

All actions are queued using requestAnimationFrame which makes this tweening engine perfect for actions that will trigger paint jobs or layout calculations in the browser.

start

If you passed paused: true to options, start will allow you to kick off the tweening.

import { Tween } from 'phena'

const tween = new Tween({ from: 1, to: 10, duration: 2000, paused: false })

tween.start()

cancel

Stop the tweening at any time.

import { Tween } from 'phena'

const tween = new Tween({ from: 1, to: 10, duration: 2000 })

tween.cancel()

The library doesn't support pause and resume actions yet.

Available options

List of properties you can pass to options object:

  • from required, initial numeric value
  • to required, final numberic value
  • duration required, tweening time in milliseconds
  • delay, delay time in milliseconds
  • onUpdate, function to execute on each value update
  • onComplete, function to execute when tweening has finished
  • paused, don't start tweening on instantiation, false by default
  • ease, function to alter the rate of change in the value pass to onUpdate

Contributing

To contribute Node.js and yarn are required.

Before commit make sure to follow conventional commits specification and check all tests pass by running yarn test.

Disclaimer

phena works similar to basic time based tweening utility, but internally it relies on enqueueing callbacks in the paint thread so it's ideal for scheduling animation jobs.

This package is not an animation library and has no intentions to become one, so it won't expose a richful API like other tools out there. For now, it just provides the minimum set of options to iterate over value updates, focusing on animation of DOM elements.