Show:

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 Function

    The 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 Number

    The number of milliseconds the animation should run

  • ease String | Function

    The key of the ease function in Q.Animation.ease object, or another ease function

  • [until=1] Number optional

    Optionally specify the position at which to pause the animation

  • params Object

    Optional parameters to pass to the callback

Item Index

Properties

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 optional

    optionally 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 optional

    optionally specify the position at which to pause the animation

play

(
  • callback
  • duration
  • ease
  • [until=1]
  • params
)
static

Play the animation

Parameters:

  • callback Function

    The 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 Number

    The number of milliseconds the animation should run

  • ease String | Function

    The key of the ease function in Q.Animation.ease object, or another ease function

  • [until=1] Number optional

    Optionally specify the position at which to pause the animation

  • params Object

    Optional parameters to pass to the callback

render

(
  • [position]
)

Render a given frame of the animation

Parameters:

  • [position] Number optional

    defaults to current position

rewind

()

Rewind the animation by pausing and jumping to position 0

Properties

ease

Object

Ease functions for animations Contains "linear", "bounce", "smooth" and "inOutQuintic". Feel free to add more.

fps

Number

The frames per second, used if requestAnimationFrame isn't defined