MCPcopy
hub / github.com/greensock/GSAP / animation

Function animation

esm/GSDevTools.js:997–1159  ·  view source on GitHub ↗
(anim)

Source from the content-addressed store, hash-verified

995 }
996 },
997 animation = function animation(anim) {
998 var ts = parseFloat(timeScale.options[timeScale.selectedIndex].value) || 1,
999 tl,
1000 maxDuration;
1001
1002 if (!arguments.length) {
1003 return selectedAnimation;
1004 }
1005
1006 if (_isString(anim)) {
1007 anim = _getAnimationById(anim);
1008 } //console.log("animation() ", anim.vars.id);
1009
1010
1011 if (!(anim instanceof Animation)) {
1012 console.warn("GSDevTools error: invalid animation.");
1013 }
1014
1015 if (anim.scrollTrigger) {
1016 console.warn("GSDevTools can't work with ScrollTrigger-based animations; either the scrollbar -OR- the GSDevTools scrubber can control the animation.");
1017 }
1018
1019 if (anim === selectedAnimation) {
1020 return;
1021 }
1022
1023 if (selectedAnimation) {
1024 selectedAnimation._inProgress = inProgress;
1025 selectedAnimation._outProgress = outProgress;
1026 }
1027
1028 selectedAnimation = anim;
1029
1030 if (linkedAnimation) {
1031 ts = linkedAnimation.timeScale();
1032
1033 if (linkedAnimation._targets && linkedAnimation._targets[0] === declaredAnimation) {
1034 declaredAnimation.resume();
1035 linkedAnimation.kill();
1036 }
1037 }
1038
1039 inProgress = selectedAnimation._inProgress || 0;
1040 outProgress = selectedAnimation._outProgress || 100;
1041 inPoint.style.left = inProgress + "%";
1042 outPoint.style.left = outProgress + "%";
1043
1044 if (_fullyInitialized) {
1045 //don't record inProgress/outProgress unless we're fully instantiated because people may call GSDevTools.create() before creating/defining their animations, thus the inTime/outTime may not exist yet.
1046 record("animation", selectedAnimation.vars.id);
1047 record("in", inProgress);
1048 record("out", outProgress);
1049 }
1050
1051 startTime = 0;
1052 maxDuration = vars.maxDuration || Math.min(1000, _getClippedDuration(selectedAnimation));
1053
1054 if (selectedAnimation === _recordedRoot || vars.globalSync) {

Callers 2

onChangeAnimationFunction · 0.70
initializeFunction · 0.70

Calls 15

timeScaleMethod · 0.80
resumeMethod · 0.80
durationMethod · 0.80
pauseMethod · 0.80
timeMethod · 0.80
seekMethod · 0.80
_isStringFunction · 0.70
_getAnimationByIdFunction · 0.70
recordFunction · 0.70
_getClippedDurationFunction · 0.70
_mergeFunction · 0.70
playFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…