Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes call array compacting. Solves #308. #317

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions velocity.js
Expand Up @@ -3150,13 +3150,6 @@ return function (global, window, document, undefined) {
/* Once the final element in this call's element set has been processed, push the call array onto
Velocity.State.calls for the animation tick to immediately begin processing. */
if (elementsIndex === elementsLength - 1) {
/* To speed up iterating over this array, it is compacted (falsey items -- calls that have completed -- are removed)
when its length has ballooned to a point that can impact tick performance. This only becomes necessary when animation
has been continuous with many elements over a long period of time; whenever all active calls are completed, completeCall() clears Velocity.State.calls. */
if (Velocity.State.calls.length > 10000) {
Velocity.State.calls = compactSparseArray(Velocity.State.calls);
}

/* Add the current call plus its associated metadata (the element set and the call's options) onto the global call container.
Anything on this call container is subjected to tick() processing. */
Velocity.State.calls.push([ call, elements, opts, null, promiseData.resolver ]);
Expand Down Expand Up @@ -3338,6 +3331,13 @@ return function (global, window, document, undefined) {
Call Iteration
********************/

/* To speed up iterating over this array, it is compacted (falsey items -- calls that have completed -- are removed)
when its length has ballooned to a point that can impact tick performance. This only becomes necessary when animation
has been continuous with many elements over a long period of time; whenever all active calls are completed, completeCall() clears Velocity.State.calls. */
if (Velocity.State.calls.length > 10000) {
Velocity.State.calls = compactSparseArray(Velocity.State.calls);
}

/* Iterate through each active call. */
for (var i = 0, callsLength = Velocity.State.calls.length; i < callsLength; i++) {
/* When a Velocity call is completed, its Velocity.State.calls entry is set to false. Continue on to the next call. */
Expand Down