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

Function updateProgress

esm/GSDevTools.js:783–849  ·  view source on GitHub ↗
(force)

Source from the content-addressed store, hash-verified

781 }
782 })[0],
783 updateProgress = function updateProgress(force) {
784 // NOTE: "force" is actually the "time" when this method gets called by the gsap.ticker!
785 if (progressDrag.isPressed && force !== true) {
786 return;
787 }
788
789 var p = !loopEnabled && selectedAnimation._repeat === -1 ? selectedAnimation.totalTime() / selectedAnimation.duration() * 100 : linkedAnimation.progress() * 100 || 0,
790 repeatDelayPhase = selectedAnimation._repeat && selectedAnimation._rDelay && selectedAnimation.totalTime() % (selectedAnimation.duration() + selectedAnimation._rDelay) > selectedAnimation.duration(),
791 target;
792
793 if (p > 100) {
794 p = 100;
795 }
796
797 if (p >= outProgress) {
798 if (loopEnabled && !linkedAnimation.paused() && !progressDrag.isDragging) {
799 if (!repeatDelayPhase) {
800 p = inProgress;
801 target = linkedAnimation._targets && linkedAnimation._targets[0];
802
803 if (target === selectedAnimation) {
804 //in case there are callbacks on the timeline, when we jump back to the start we should seek() so that the playhead doesn't drag [backward] past those and trigger them.
805 target.seek(startTime + (endTime - startTime) * inProgress / 100);
806 }
807
808 if (selectedAnimation._repeat > 0 && !inProgress && outProgress === 100) {
809 if (selectedAnimation.totalProgress() === 1) {
810 linkedAnimation.totalProgress(0, true).resume();
811 }
812 } else {
813 linkedAnimation.progress(p / 100, true).resume();
814 }
815 }
816 } else {
817 if (p !== outProgress || selectedAnimation._repeat === -1) {
818 p = outProgress;
819 linkedAnimation.progress(p / 100);
820 }
821
822 if (!paused && (outProgress < 100 || selectedAnimation.totalProgress() === 1 || selectedAnimation._repeat === -1)) {
823 pause();
824 }
825 }
826 } else if (p < inProgress) {
827 p = inProgress;
828 linkedAnimation.progress(p / 100, true);
829 }
830
831 if (p !== progress || force === true) {
832 progressBar.style.left = inProgress + "%";
833 progressBar.style.width = Math.max(0, p - inProgress) + "%";
834 playhead.style.left = p + "%";
835 timeLabel.innerHTML = linkedAnimation._time.toFixed(2);
836 durationLabel.innerHTML = linkedAnimation._dur.toFixed(2);
837
838 if (dragged) {
839 playhead.style.transform = "translate(-50%,0)";
840 playhead._gsap.x = "0px";

Callers 5

resetInOutFunction · 0.70
GSDevToolsFunction · 0.70
onPressSeekBarFunction · 0.70
updateRootDurationFunction · 0.70
initializeFunction · 0.70

Calls 9

durationMethod · 0.80
pausedMethod · 0.80
seekMethod · 0.80
totalProgressMethod · 0.80
resumeMethod · 0.80
pauseFunction · 0.70
togglePlayPauseFunction · 0.70
totalTimeMethod · 0.45
progressMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…