
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
animation-timer
Advanced tools
Low level, lightweight and precise animation utility. Your tick handlers get a duration between 0-1. That's it.
Low level animation / LFO module suitable for graphics, games development and audio processing. It uses Tick as a central controller, giving the ability to pause and resume individual or all animations currently in progress.
Animation Timer literally does nothing but supply you with a normalised, abstract 'percentage time elapsed' value.
This module works extremely well with Functional Easing which can wrap your tick handlers with easing functions so that you get eased time values instead of raw linear time elapsed values. It's cool. Not bow-tie cool, but pretty pretty cool. Together they pretty much eliminate most of the tediously repetitive math around dealing with animations and easing and let you concentrate on your actual functionality.
// some dependencies...
var quat = require('gl-matrix-quat');
var mat4 = require('gl-matrix-mat4');
var Easer = require('functional-easing').Easer;
// animation timer module...
var AnimationTimer = require('animation-timer').AnimationTimer;
// making two quaternions.
var q1 = quat.fromValues(0.5, 0.3, 1.0, 1.0);
var q2 = quat.fromValues(0.1, 0.9, 0.2, 1.0);
// make an easing function..
var easer = new Easer().using('in-cubic');
var animation = new AnimationTimer()
.duration('5s')
// wrap our tick handler with our easing function...
.on('tick', easer(function (percent){
var out = quat.create();
quat.slerp(out, q1, q2, percent);
// do something with our new quaternion...
}));
animation.bounce();
Browserify/NPM
$ npm install --save animation-timer
var AnimationTimer = require('animation-timer').AnimationTimer;
Creates a new instance of AnimationTimer;
var animation = new AnimationTimer();
Specifies how long a single iteration of the animation should last for. Can be given in miliseconds or as a string, '200ms', '2s', '1m' etc.
When the tick handler fires, the value passed as a parameter is the percentage time elapsed (between 0 and 1) since the animation began.
play or reverse will go from 0 to 1 over the duration.loop or loopReverse will loop every duration, each cycle behaving like play or reversebounce will toggle between play and reverse every duration.// create a triangle wave LFO for the Web Audio API, toggling direction every beat
var ani = new AnimationTimer()
.duration(500)
.on('tick', function(percent){
filter.frequency.value = lerp(200,500, percent);
})
.loop();
Subscribe to an event. The built in events are:
Subscribe to the tick event.
func is passed percent as a parameter. This is value between 0 and 1This handler can be used to do any processing work required after an animation is concluded.
.play() or .reverse() animations are finishedfunc is passed the current timeThis handler can be used in leui of a tick handler in order to trigger events that occur every duration.
.loop() or .loopReverse() animations are about to start the next iterationfunc is passed the current timeThis handler can be used in leui of a tick handler in order to trigger events that occur every duration.
.bounce() animations are about to toggle direction.func is passed the current timeTechnically you can trigger any event manually, including any custom events you so desire.
Fires a tick handler every animationFrame until the duration has elapsed, at which point it stops.
By default it begins immediately but optionally an absolute start time can be specified.
time in the tick handler climbs from 0 to 1, representing the percentage duration elapsed.animation
.duration(1000)
.on('tick', function(time){
console.log(time);
})
.play();
Fires a tick handler every animationFrame indefinitely.
By default it begins immediately but optionally an absolute start time can be specified.
time in the tick handler climbs from 0 to 1, representing the percentage duration elapsed.duration, time loops back to 0 and starts againanimation
.duration(1000)
.on('tick', function(time){
console.log(time);
})
.loop();
Fires a tick handler every animationFrame indefinitely.
By default it begins immediately but optionally an absolute start time can be specified.
time in the tick handler climbs from 0 to 1, then 1 to 0, then 0 to 1 and so on.duration, time toggles between climbing and falling.animation
.duration(1000)
.on('tick', function(time){
console.log(time);
})
.bounce();
Fires a tick handler every animationFrame until the duration has elapsed, at which point it stops.
By default it begins immediately but optionally an absolute start time can be specified.
time in the tick handler falls from 1 to 0, representing the inverted percentage duration elapsed.animation
.duration(1000)
.on('tick', function(time){
console.log(time);
})
.reverse();
Fires a tick handler every animationFrame indefinitely
By default it begins immediately but optionally an absolute start time can be specified.
time in the tick handler falls from 1 to 0, representing the inverted percentage duration elapsed.duration, time loops back to 0 and starts againanimation
.duration(1000)
.on('tick', function(time){
console.log(time);
})
.loopReverse();
## Control
Immediately stops the running animation. Stopped animations cannot be resumed, only restarted.
animation.stop();
Pauses the animation.
animation.pause();
Resumes an animation
animation.resume();
Assuming you have grunt-cli already installed, and you've cloned the repo:
# Just the once...
$ npm install
grunt test
This module is intended to replaced my much loved Tween module which, while incredibly useful has proven to be the wrong abstraction and difficult to use once stepping outside the realm of {left : 10, top : 15}. I needed a more abstract, flexible module that would give me the crucial time information and actually run animations, but not be involved in actual tweening or anything like that, making it less cumbersome and inefficent when changing vectors, matricies, quarternions etc over time.
There is no roadmap as much, although possible useful functions would be 'stopBeforeLooping()' for looping and bouncing animations. Debating with myself whether to support 'playAt(tick.now() + delay)' or 'stopAt(tick.now() + delay)' or whether a separate scheduling module would be more appropriate.
MIT
FAQs
Low level, lightweight and precise animation utility. Your tick handlers get a duration between 0-1. That's it.
The npm package animation-timer receives a total of 84 weekly downloads. As such, animation-timer popularity was classified as not popular.
We found that animation-timer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.