MCPcopy Index your code
hub / github.com/bendc/animateplus / tick

Function tick

animateplus.js:341–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339};
340
341const tick = now => {
342 const {all} = rAF;
343 all.forEach(object => {
344 trackTime(object, now);
345 const progress = getProgress(object);
346 const {
347 element,
348 keyframes,
349 loop,
350 optimize,
351 direction,
352 change,
353 easing,
354 duration,
355 gaussian,
356 end,
357 options
358 } = object;
359
360 // object is an animation
361 if (direction) {
362 let curve = progress;
363 switch (progress) {
364 case 0:
365 if (direction == "alternate") reverseKeyframes(keyframes);
366 break;
367 case 1:
368 if (loop)
369 resetTime(object);
370 else {
371 all.delete(object);
372 if (optimize && element) accelerate(element);
373 if (gaussian) clearBlur(element, gaussian);
374 }
375 if (end) end(options);
376 break;
377 default:
378 curve = ease(easing, progress);
379 }
380 if (gaussian) setDeviation(object, curve);
381 if (change && end) change(curve);
382 if (element) Object.assign(element.style, createStyles(keyframes, curve));
383 return;
384 }
385
386 // object is a delay
387 if (progress < 1) return;
388 all.delete(object);
389 end(duration);
390 });
391
392 if (all.size) requestAnimationFrame(tick);
393};
394
395document.addEventListener("visibilitychange", () => {
396 const now = performance.now();

Callers

nothing calls this directly

Calls 9

trackTimeFunction · 0.85
getProgressFunction · 0.85
reverseKeyframesFunction · 0.85
resetTimeFunction · 0.85
accelerateFunction · 0.85
clearBlurFunction · 0.85
easeFunction · 0.85
setDeviationFunction · 0.85
createStylesFunction · 0.85

Tested by

no test coverage detected