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

Unit-Bezier

v1.0.3

Published

Combination of Mozilla and Chromium implementations of Bezier Curves used for animation interpolation for Javascript

Downloads

4,864

Readme

Unit-Bezier

A Combination of Mozilla and Chromium implementations of Bezier Curves used for animation interpolation for Javascript

Unit-Bezier takes optimizations from both Mozilla and Chromium timing function code and combines them into performant Javascript. It is compliant with both browsers' tests.

Getting Started

Download / Clone

Install with npm:

npm install Unit-Bezier

Clone the repo using Git:

git clone --bare https://github.com/jacobcpeters/Unit-Bezier.git

Alternatively you can download this repository.

Using Unit-Bezier

Use the 'new' operator to construct a new UnitBezier object for your function/module/class. The first parameter of the constructor is an array that contains the control points for the Bezier Curve [x1, y1, x2, y2]. The second parameter is the epsilon that controls the desired accuracy of the estimations.

var bezier = new UnitBezier(controlPoints, epsilon);

Easing Aliases

Easy to use aliases are available for common easing types in the UnitBezier.easings object.

var bezier = new UnitBezier(UnitBezier.easings.easeInOut, 0.005);
Table of available aliases:

| Easing Name | Control Points | |:--------------|:-------------------------------| | linear | [0.0, 0.0, 1.0, 1.0] | | ease | [0.25, 0.1, 0.25, 1.0] | | easeIn | [0.42, 0.0, 1.0, 1.0] | | easeInOut | [0.42, 0.0, 0.58, 1.0] | | easeOut | [0.0, 0.0, 0.58, 1.0] | | easeInBack | [0.6, -0.28, 0.735, 0.045] | | easeOutBack | [0.175, 0.885, 0.32, 1.275] | | easeInOutBack | [0.680, -0.550, 0.265, 1.550] |

####Code example:

var bezier = new UnitBezier([0.0, 0.0, 1.0, 1.0], 0.000001), //linear Bezier Curve
    target = document.getElementById('animated-opacity'),
    animationLength = 1000, // 1000ms = 1s
    startTime = Date.now();
    
function animateOpacity() {
    var timeSinceAnimationStarted = Date.now() - startTime;
    
    target.style.opacity = 1 * bezier.calc(timeSinceAnimationStarted / animationLength);
    
    if(timeSinceAnimationStarted < animationLength) {
        requestAnimationFrame(animateOpacity);
    }
}

requestAnimationFrame(animateOpacity);

Feature requests

If Unit-Bezier doesn't support a feature you require, please put a request in the issues tracker.

License

© Jacob Peters, 2015. Licensed under an MIT license.