Skip to content
Ryc O'Chet edited this page Feb 1, 2018 · 1 revision
- NOTE: This documentation is for Velocity v2.

Option: Loop

Set the loop option to an integer to specify the number of times an animation should alternate between the values in the call's property map and the element's values prior to the call:

// Alternate the height between 5em and 10em twice.
element.velocity({ height: ["10em", "5em"] }, { loop: 2 });

If the begin or complete callbacks are used with a looped call, they are triggered once each - at the very beginning of the first loop animation and when the loop is stopped, respectively. They are not re-triggered for each loop alternation.

Instead of passing in an integer, you can pass in true to trigger infinite looping:

element.velocity({ height: ["10em", "5em"] }, { loop: true });

Be sure to stop one infinite loop before triggering another on the same element. A loop can be stopped with the "stop" and "finish" commands.

See also: [repeat](Option - Repeat.md)