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

@createjs/tweenjs

v2.0.0-beta.4

Published

A simple but powerful tweening / animation library for Javascript. Part of the CreateJS suite of libraries.

Downloads

9,001

Readme

2.0 BETA

This branch is in beta. Reporting issues is appreciated, please mention that it is for 2.0 in the issue body.

Unit tests failing is a known issue, please don't report this.

Plugin architecture is incomplete, as such they are expected to break.

TweenJS is a simple tweening library for use in JavaScript. It was developed to integrate well with the EaselJS library, but is not dependent on or specific to it (though it uses the same Ticker and Event classes by default). It supports tweening of both numeric object properties & CSS style properties.

Installation

NPM

npm install @createjs/tweenjs --save

CDN

<script src="https://code.createjs.com/2.0/tweenjs.min.js"></script>

Simple Example

The API is simple but very powerful, making it easy to create complex tweens by chaining commands.

import { Tween } from "@createjs/tweenjs";
let tween = Tween.get(target)
	.to({ x: 300 }, 400)
	.set({ label: "hello!" })
	.wait(500)
	.to({ alpha: 0, visible: false }, 1000)
	.call((p1, p2) => { ... }, [ 10, true ]); // p1 === 10, p2 === true, this === target

The example above will create a new Tween instance that:

  • tweens the target to an x value of 300 over 400ms and sets its label to "hello!"
  • waits 500 ms
  • tweens the target's alpha to 0 over 1s & sets its visible to false
  • calls the onComplete function

Tweens are composed of two elements: steps and actions.

Steps define the tweened properties and always have a duration associated with them (even if that duration is 0). Steps are defined with the "to" and "wait" methods. Steps are entirely deterministic. You can arbitrarily set a tween's position, and it will always set the same properties for that position.

Actions do not have a duration, and are executed between steps. They are defined with the call(), set(), play(), and pause() methods. They are guaranteed to execute in the correct order, but not at the precise moment in time that is indicated in the sequence. This can lead to indeterminate results, especially when tweens are interacting via the play and pause actions.

Tweens support a number of configuration properties, which are specified as the second param when creating a new tween:

Tween.get(target, {
	loop: true,
	useTicks: true,
	css: true,
	ignoreGlobalPause: true
}).to(etc...);

All configuration properties default to false. The properties are:

loop - indicates whether the tween should loop when it reaches the end

useTicks - the tween will use ticks for duration instead of milliseconds

css - enables css mapping for some css properties

ignoreGlobalPause - the tween will continue ticking even when Ticker is paused.

When using Tween.get(), you can also specify true as the third parameter to override any active tweens on the target.

Tween.get(target, null, true); // this will remove any existing tweens on the target.

Support and Resources

  • Find examples and more information at the TweenJS web site.
  • Read the documentation.
  • Discuss, share projects, and interact with other users on reddit.
  • Ask technical questions on Stack Overflow.
  • File verified bugs or formal feature requests using Issues on GitHub.
  • There is a Google Group for discussions and support.
  • Have a look at the included examples for more in-depth instructions.

It was built by gskinner.com, and is released for free under the MIT license, which means you can use it for almost any purpose (including commercial projects). We appreciate credit where possible, but it is not a requirement.

Thanks

Special thanks to Robert Penner for his easing equations, which form the basis for the Ease class.