(anim)
| 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 | } |
no test coverage detected
searching dependent graphs…