jw-animator
A static and stateful instance which hooks into requestAnimationFrame. It uses setInterval if requestAnimationFrame is not available.
Install
Methods
Method | Parameters | Description |
---|---|---|
setFPS |
fps : integer |
set a specific frame rate for the animation. |
setPauseOnHidden |
hidden : boolean |
set whether the animations to be paused when the page loses focus. |
setResumeOnShown |
shown : boolean |
set whether the animations to be resume when the page regains focus. |
start |
start the animation loop. | |
pause |
pause the animation loop. | |
resume |
resume the animation loop. | |
stop |
stop the animation loop. | |
add |
handler : function |
bind an event handler to the animate event. A time difference will be passed as a parameter (in seconds). Returns a method to unbind. |
onStart |
handler : function |
bind an event handler to the start event. Returns a method to unbind. |
onPause |
handler : function |
bind an event handler to the pause event. Returns a method to unbind. |
onResume |
handler : function |
bind an event handler to the resume event. Returns a method to unbind. |
onStop |
handler : function |
bind an event handler to the stop event. Returns a method to unbind. |
Usage
; /* Create an instance of an animator. */let animator = ; /** Set a specific frame rate for the animation. */animator; /* Set the animations to be paused when the page loses focus. */animator; /* Set the animations to be resume when the page regains focus. */animator; /** Start the animation loop. */animatorstart; /** Pause the animation loop. */animator; /** Resume the animation loop. */animator; /** Stop the animation loop. */animator; /** Bind an event handler to the animate event. */let remove = animator; /** Unbind an event handler from the animate event. */; /** Bind an event handler to the start event. */let removeStart = animator; /** Unbind an event handler from the start event. */; /** Bind an event handler to the pause event. */let removePause = animator; /** Unbind an event handler from the pause event. */; /** Bind an event handler to the resume event. */let removeResume = animator; /** Unbind an event handler from the resume event. */; /** Bind an event handler to the stop event. */let removeStop = animator; /** Unbind an event handler from the stop event. */;