Skip to content
Ryc O'Chet edited this page Jun 3, 2018 · 2 revisions
- NOTE: This documentation is for Velocity v2.

Option: Complete

Complete is the converse of the begin option. Pass the complete option a function to be triggered once the animation has finished (see VelocityCallback in index.d.ts). The function is executed once per call, even if multiple elements are being animated at once. Further, if a call is looped, the complete callback only fires once - at the end of the last loop alternation.

The callback is passed the element array as both its context and its first argument. To access these elements individually, you must iterate over the array. This array also has .velocity(...) available on it for addressing directly.

The second argument is passed an AnimationCall object (see velocity.d.ts in the source for full details). The most useful member of this is the .element member, which will be the last element to animate from the element array (not necessarily the last entry in the array).

element.velocity({
    opacity: 0
}, {
    complete: function(elements, activeCall) {
        console.log("Finishing " + elements.length + " elements:", elements);
    }
});