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

timaline

v0.0.22

Published

timaline is a requestAnimationFrame based tasks scheduler.

Downloads

10

Readme

timaline

Timaline is a requestAnimationFrame based tasks scheduler.

To Do

  • [x] Reduce RAF Delta impact by "prev or next" frame
  • [x] Speed
  • [x] Repeat
  • [x] User custom loop (manually update)
  • [x] Disable RAF when web page is not active
  • [ ] Playback control
  • [ ] RAF Delta impact reducing by average calculation
  • [ ] Reduce RAF Delta aftereffect

Installation

NPM

Demo

Test timaline in your browser

Features

  • Set callback functions
  • Wait time in millisecond
  • AddClass to a node
  • RemoveClass to a node
  • Destroy everything
  • Control speed
  • Control repeat
  • Update manually
  • Pause when tab is not visible

Browser compatibility

IE 10+

Documentation

Use

var Timaline = require('Timaline');

Options

You can pass 3 options to constructor, and you can combine them :


var timeline = new Timaline({
	loop: false, // default : true
	speed: 0.5, // default : 1
	repeat: 3 // default : 0
});

Methods

.wait(time)

Wait time.

properties
time (Integer)

Time to wait in millisecond

.set(callback)

Call your function.

properties
callback (Function)

The fonction you need to call

.addClass(el, classname)

AddClass shortcut.

properties
el (Node)

Your dom element

classname (String)

Your class name

.removeClass(el, classname)

RemoveClass shortcut.

properties
el (Node)

Your dom element

classname (String)

Your class name

.destroy()

Roughly destroy your timeline.

speed (Float)

Speed will control entire timeline (default: 1)

repeat (Float)

Repeat your timeline as many times as you like (default: 0)

Informations

When you set a callback, infos are available :

var delay = new Timaline();

delay
	.wait(200)
		.set(function(infos){
			console.log(infos);
		});
var infos = {
	index: 2, // The index of your task
	keyframe: {
		forecast: 3000, // Time forecast by set wait time
		real: 2996, // Real time (with RAF Delta)
		shift:  -4 // Shift between both
	}
};

Examples

Simple task

This example is a simple delayed task, similar as a simple window.setTimeout :

var delay = new Timaline();

delay
	.wait(200)
		.set(function(infos){
			console.log(infos);
		});

Chained tasks

This example is a chained tasks :

var timeline = new Timaline();

timeline
	.wait(1000)
		.set(function(infos){
			console.log('task index :' + infos.index );
		})
	.wait(2000)
		.set(function(infos){
			console.log('task index :' + infos.index );
		});

Shortcuts use

If you need, you can use shortcuts methods during your timeline : (consider that the used classes exist in your stylesheet)

var $header = document.getElementById('header');
var $container = document.getElementById('container');
var $footer = document.getElementById('footer');

var hidePage = new Timaline();

hidePage
	.set(function(infos){
		console.log('This page will disappear in a while.');
	})
	.wait(1000)
		.addClass($header, 'fadeOut')
	.wait(800)
		.removeClass($container, 'shown')
	.wait(1000)
		.addClass($footer, 'scaleOut')
	.set(function(infos){
		console.log('That\'s all folks!');
	});

Update manually

This example show how to update Timaline with your own loop :

var delay = new Timaline({
	raf: false
});

function loop( timestamp ) {
	delay.update( timestamp );
	requestAnimationFrame( loop );
}

requestAnimationFrame( loop );

delay
	.wait(200)
		.set(function(infos){
			console.log(infos);
		});

Destroy on the fly

A timeline is destructs when it is finished, but sometimes you need to roughly destroy it before the end :

// Create a new timeline

var timeline = new Timaline();

timeline
	.wait(3000)
	.set(function(infos){
		console.log('I\'ll never be call.');
	})
	.wait(1000)
	.set(function(infos){
		console.log('me too.');
	});

// ..and create a new one that will remove
// the first one before its end

var destroy = new Timaline();

destroy
	.wait(1000)
	.set(function(infos){
		timeline.destroy();
	});