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

Function animation

src/GSDevTools.js:745–859  ·  view source on GitHub ↗
(anim)

Source from the content-addressed store, hash-verified

743 }
744 },
745 animation = function(anim) {
746 let ts = parseFloat(timeScale.options[timeScale.selectedIndex].value) || 1,
747 tl, maxDuration;
748 if (!arguments.length) {
749 return selectedAnimation;
750 }
751 if (_isString(anim)) {
752 anim = _getAnimationById(anim);
753 }
754 //console.log("animation() ", anim.vars.id);
755 if (!(anim instanceof Animation)) {
756 console.warn("GSDevTools error: invalid animation.");
757 }
758 if (anim.scrollTrigger) {
759 console.warn("GSDevTools can't work with ScrollTrigger-based animations; either the scrollbar -OR- the GSDevTools scrubber can control the animation.");
760 }
761 if (anim === selectedAnimation) {
762 return;
763 }
764 if (selectedAnimation) {
765 selectedAnimation._inProgress = inProgress;
766 selectedAnimation._outProgress = outProgress;
767 }
768 selectedAnimation = anim;
769 if (linkedAnimation) {
770 ts = linkedAnimation.timeScale();
771 if (linkedAnimation._targets && linkedAnimation._targets[0] === declaredAnimation) {
772 declaredAnimation.resume();
773 linkedAnimation.kill();
774 }
775 }
776 inProgress = selectedAnimation._inProgress || 0;
777 outProgress = selectedAnimation._outProgress || 100;
778 inPoint.style.left = inProgress + "%";
779 outPoint.style.left = outProgress + "%";
780 if (_fullyInitialized) { //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.
781 record("animation", selectedAnimation.vars.id);
782 record("in", inProgress);
783 record("out", outProgress);
784 }
785 startTime = 0;
786 maxDuration = vars.maxDuration || Math.min(1000, _getClippedDuration(selectedAnimation));
787 if (selectedAnimation === _recordedRoot || vars.globalSync) {
788 _merge();
789 linkedAnimation = _rootTween;
790 _rootInstance && _rootInstance !== _self && console.warn("Error: GSDevTools can only have one instance that's globally synchronized.");
791 _rootInstance = _self;
792 if (selectedAnimation !== _recordedRoot) {
793 tl = selectedAnimation;
794 endTime = tl.totalDuration();
795 if (endTime > 99999999) { //in the case of an infinitely repeating animation, just use a single iteration's duration instead.
796 endTime = tl.duration();
797 }
798 while (tl.parent) {
799 startTime = (startTime / tl._ts) + tl._start;
800 endTime = (endTime / tl._ts) + tl._start;
801 tl = tl.parent;
802 }

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…