animation
Handles Animation Timing and Handling for you.
Uses requesAnimationFrame when running on browser side.
Installation
$ npm install animation
Usage
// get a tick every 100msvar animation = frame:'100ms';animation;animationstart;
// get next tick with delta time to last tickvar animation = frame:'100ms';var { // do your animation stuff if processstdout animation; else var t = processstdout; };animation; // no start required
// doesnt really matter when its executed, but it should happen// (use this in browser if you want to update your dom on requesAnimationFrame)var animation = ;animationstart;animation;
Δt adapters for DOM and jQuery depending on this module to do heavy DOM manipulation like insertion only on requesAnimationFrame.
surrender-cube uses this module to draw a rotating wireframe cube in terminal.
ceilingled uses this to draw images fetched from superfeedr to draw either on SDL or on a LED wall.
Animation
animation = // defaults timeoutexecution:'20ms' // allowed execution time per animation tick timeout execution: '5ms' // allowed execution time per animation tick timeout: null // maximum time of a animation tick interval else runs continuously if null toggle: false // if true animation pauses and resumes itself when render queue gets empty or filled frame: '16ms' // time per frame;
Creates a new Animation controller.
animation.start
animationstart;
Starts animation.
animation.stop
animation;
Stops animation.
animation.pause
animation;
When autotoggle is enabled the Animation pauses itself if the render queue is empty.
animation.resume
animation;
When autotoggle is enabled the Animation resumes itself when the render queue gets filled again after it was emtpy.
animation.nextTick
animation;
Given callback gets called on next animation tick when running and not paused.
Events
'start'
animation;
Emits start
event every time the animation gets started.
'stop'
animation;
Emits stop
event every time the animation gets stopped.
'pause'
animation;
Emits pause
event every time the animation gets paused.
'resume'
animation;
Emits resume
event every time the animation gets resumed.
'tick'
animation;
Emits tick
event every time the animation executes a animation tick.
dt
is the time since last animation tick finished.
Use this to do your animation stuff.