Giter VIP home page Giter VIP logo

keyframely's Introduction

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 :)

keyframely's People

Contributors

chrisdickinson avatar

Stargazers

Greg avatar

Watchers

Greg avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.