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

ticker-js

v1.0.3

Published

Event-emitting time keeper for browser friendly render cycles

Downloads

5

Readme

100% test coverage

ticker-js

Event-emitting time keeper for browser friendly render cycles

Browser-based module that fires events at a given interval to facilitate interactions on a timeline. Tries to help facilitate measure/render grouping by firing two separate events at different moments in the process tick.

  • The update event is when any measurement or calculations should occur.
  • The render event is when the results of any measurements are applied to the DOM.

Installation

Install via npm:

$ npm i ticker-js --save

API

All properties should be accessed via the getter and setter methods.

| method | params | description | |-------------|----------------|-------------------------------------------------------| | start | | Starts the instance, firing its events | | stop | | Stops the instance, stopping events from firing | | setFps | number: fps | Throttles the ticker to the passed value | | getFps | | Returns the current fps setting as a number or null | | isTicking | | Returns boolean indicating if the instance is running | | destroy | | Destroys the instance, removing all listeners |

Events

All events pass the same event object defined below.

| event | description | |----------|------------------------------------------------------------| | update | DOM measurements and calculations should occur when fired. | | render | DOM modification should occur when fired. |

Event object

The two events pass listeners an event object as defined below.

| type | name | description | |--------------------|----------------|------------------------------------------------| | @property {object} | data | event data object | | @property {number} | data.fps | frames per second | | @property {number} | data.trueFps | un-throttled frames per second | | @property {number} | data.runtime | the total duration of the ticker while ticking | | @property {number} | data.delta | time since last render | | @property {number} | data.time | current lifespan of render cycle | | @property {number} | data.now | current time |

Usage

Instantiate and attach any listeners.

var Ticker = require('ticker-js');
var ticker = new Ticker(30);

ticker.on('update', function (evt) {
  // measure
});

ticker.on('render', function (evt) {
  // render
});

Instances do not auto-run. You must call the start method for the events to begin firing.

ticker.start();

Once running, the update and render events will begin firing at the ticker's fps interval. If fps is unset, the ticker is not throttled, and will tick as close to 60 fps as possible.