Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A JQuery-less rewrite of https://github.com/KuraFire/runloop -- usable in Node or in-browser.
branch: master

This branch is even with chrisdickinson:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
LICENSE
README.md
package.json

README.md

Keyframely (a jQuery-less Runloop)

A rewrite of runloop that removes the dependency on jQuery. Props to KuraFire for the original -- it's an awesome idea.

Usage

In node:

var puts = require('util').puts,
    loop = require('keyframely').loop;

var ourLoop = loop(Math.round.bind(Math), loop.easings.cubic_out);

ourLoop.addKey('0%', function(ctls) {
  puts('0');
});
ourLoop.addKey('6%', function(ctls) {
  puts('6');
});
ourLoop.addKey('24%', function(ctls) {
  puts('24');
});
ourLoop.addKey('55%', function(ctls) {
  puts('55');
});

ourLoop.play(1000, function(ctls) {
  puts('done');
});

Or in browser:

<script src="keyframely.js"></script>
<script type="text/javascript">
    var ourLoop = keyframely.loop();
    ourLoop.addKey('50%', function(ctls) {
        document.write('HALLO WORLD');
    }); 

    ourLoop.play(1000, function(ctls) {
        document.write('No really hello.');
    });
</script>

The biggest deviation from the original api is that a control object is passed to the keyframe callback. It provides the following:

  • quit: Quits the loop immediately.
  • pause: Pauses the loop. Resume the loop using play on the controls object.
  • play: Continues playing the loop.

This is done so that key frames can be retrieved and used on other loops using getMap and addMap, respectively.

License

New BSD.

Why?

Runloop is a great idea, and could be used to simulate, for example, request latency in Node. Unfortunately, since it is written as a jQuery plugin, it eschews that possibility out of the gate. No ill will intended! I just want to be able to use it when I don't have access to jQuery :)

Something went wrong with that request. Please try again.