Q.Animation Class
Q.Animation class can be used to repeatedly call a function in order to animate something
Constructor
Q.Animation
-
callback
-
duration
-
ease
-
[until=1]
-
params
Parameters:
-
callback
FunctionThe function to call. It is passed the following parameters:
- x = the position in the animation, between 0 and 1
- y = the output of the ease function after plugging in x
- params = the fourth parameter passed to the run function
-
duration
NumberThe number of milliseconds the animation should run
-
ease
String | FunctionThe key of the ease function in Q.Animation.ease object, or another ease function
-
[until=1]
Number optionalOptionally specify the position at which to pause the animation
-
params
ObjectOptional parameters to pass to the callback
Methods
jump
()
Jump to a certain position in the animation. When the animation plays, the next render will use this position. Additionally, you might want to follow jump() with calls to render() and/or pause().
nextFrame
-
[position]
Render the next frame of the animation, and potentially continue playing
Parameters:
-
[position]
Number optionaloptionally render a specific position in the animation
pause
()
Pause the animation
play
-
[until=1]
Play the animation (resume after a pause)
Parameters:
-
[until=1]
Number optionaloptionally specify the position at which to pause the animation
play
-
callback
-
duration
-
ease
-
[until=1]
-
params
Play the animation
Parameters:
-
callback
FunctionThe function to call. It is passed the following parameters:
- x = the position in the animation, between 0 and 1
- y = the output of the ease function after plugging in x
- params = the fourth parameter passed to the run function
-
duration
NumberThe number of milliseconds the animation should run
-
ease
String | FunctionThe key of the ease function in Q.Animation.ease object, or another ease function
-
[until=1]
Number optionalOptionally specify the position at which to pause the animation
-
params
ObjectOptional parameters to pass to the callback
render
-
[position]
Render a given frame of the animation
Parameters:
-
[position]
Number optionaldefaults to current position
rewind
()
Rewind the animation by pausing and jumping to position 0