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 🙏

© 2026 – Pkg Stats / Ryan Hefner

distractjs

v0.1.3

Published

The post-flash JavaScript library for creating useless, resource hungry, migraine inducing animations.

Readme

distract.js

The post-flash JavaScript library for creating useless, resource hungry, migraine inducing animations.

github.com/unkhz/distract.js/

Features

  • Simplifies creation of particle based generative animations
  • Works with HTML or SVG
  • Detects vendor specific CSS properties and uses only one
  • Pure JavaScript, no library dependencies
  • Uses requestAnimationFrame for maximum performance

Demos and examples

WARNING! The screensaver demo will cause older iPhones to become unresponsive, so please be careful.

Installation

Using npm

npm install --save distractjs

Using bower

bower install --save distractjs

Documentation

Quick example

All functionality is exposed via the Distract global object, unless you're using anonymous modules in which case no global variables will be used.

The following example will create an animation with five individual 'Hello World!' texts rotating randomly around their X and Y axis.

You can also fiddle with it in Plunker

var helloLayer = new Distract.Layer({
  el:document.body,
  particleCount:5
},{
  text: 'Hello World!',
  className:'hello-particle',
  iterationSpeed: 1,
  iterationRules: [[
    // The first rule modifies the delta for the second and third rule
    {
      parse: function(rule, state, opts, particle) {
        // Use quite small modifications for smooth animation
        state.delta += (Math.random()-0.5)/10;
      }
    },

    // The second rule modifies the X rotation
    {
      property:'transform',
      propertyFunction:'rotateX',
      inc:function(rule, state, opts, particle){
        return state.delta * Math.random();
      }
    },

    // The third rule modifies the Y rotation
    {
      property:'transform',
      propertyFunction:'rotateY',
      inc:function(rule, state, opts, particle){
        return state.delta * Math.random();
      }
    }
  ]],
  initState: function(){
    return {
      delta: 0,
      style: {
        transform: {
          perspective:[300,'px'],
          rotateX:[0,'deg'],
          rotateY:[0,'deg']
        }
      }
    };
  }
});

Distract.Layer is the main controller and container of the animation. Upon instantiation it will automatically start creating new instances of Distract.Particle which represent the individual moving elements.

The first argument of the new Distract.Layer() constructor is the configuration object for the Layer. Specified values will override ones from the base configuration Distract.LayerOptions.

The second argument is the configuration object for the Distract.Particle instances that animated according to the rules that you define in the configuration. The above example defines three simple rules that manipulate the rotateX and rotateY transform functions. Partile configuration is also extended into the defaults defined in Distract.ParticleOptions.

Resource usage

The animation is based on requestAnimationframe, which means that there are infinite loops going on during the animation. When the animation needs to be stopped, it is important to clear the resources and stop the individual animation loops. This can be done with the destroy method.

helloLayer.destroy();

The animation can also be temporarily paused and restarted using the pause and animate methods.

helloLayer.pause();
helloLayer.animate();

Changelog

0.1.3  2014-11-12   Improved Layer controls
0.1.2  2014-11-05   Ability to set attributes for SVG
0.1.0  2014-11-02   Documentation and examples
0.0.1  2013-12-23   Initial release