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

value-chase

v1.1.0

Published

Creates a value chase incorporating an ease and friction.

Downloads

11

Readme

valueChase

Creates a value chase incorporating an ease and friction.

This module creates a chase between a provided value and target value. For example, if you had a dot follow every mouse click on a page, animating against the output of this module allows us to have the dot move to our current location gradually rather than immediately jumping to it. And if we move the mouse while it's traveling to its target, it will correct course smoothly.

User-defined friction, ease, and specificity (tolerance) requirements allow you to control how quickly and aggressively a value chases its target.

This module is a trait more than a class, and is meant to be augmented by other modules such as pointer-chase and scroll-chase. It extends EventEmitter, and broadcasts progress towards reaching its target.

Basic demo.

Installation

Install via npm:

$ npm i value-chase

Usage

const ValueChase = require('value-chase');
const valueChase = new ValueChase();

valueChase.on('render', evt => {
  console.log(evt.progress);
});

valueChase.start();

window.setTimeout(() => {
  valueChase.setProgress(100);
}, 1000);

Methods

Methods that accept parameters always expect numeric values.

| method | description | |---|---| | ValueChase.destroy() | Stops the module, removes all listeners, destroys its internal ticker-js instance, and broadcasts the destroyed event. | | ValueChase.start() | Starts the internal ticker-js instance and begins calculating the current value. | | ValueChase.stop() | Stops the internal ticker-js instance and pauses calculating current value. Also stops all events from being emitted. | | ValueChase.isRunning() | Whether or not the instance is currently stopped. | | ValueChase.setValue(number) | Immediately jump to the provided value and force a render. | | ValueChase.setProgress(number) | This is how we pass a target value to the motion curve calculator. This is often what needs to be overwritten if you have coordinate or vector values to update. | | ValueChase.setFriction(number) | Set friction used by calculator. | | ValueChase.setTolerance(number) | Set the specificity requirements necessary to indicate when value has reached target. |

Events

This module emits update and render events. All calculations and measurements should occur on update, and the actual rendering of those measurements within the DOM should occur on render.

For example, if we want to have an object slide horizontally as we scroll vertically, determining the x-axis transform based on a value should be done on update. Actually applying the transform via a style tag is done on render.

| event | description | |---|---| | render | Apply DOM transformations / animations | | update | Calculate any necessary animation values |

Tests, Coverage, and Documentation

Tests, coverage reports, and documentation can be run / generated by calling their appropriate npm script. See the package.json for script names.