Capítulo 172 de 411
Given an animation that already has a ScrollTrigger, this helper returns the scroll position corresponding to any progress point in that animation (0 = start, 1 = end), so you can scroll the page to exactly where a scroll-driven animation begins, ends, or sits at any point in between.
animation.scrollTrigger.start/.end and interpolates by the given progress.containerAnimation case (horizontal scroll setups) by mapping through the container's own ScrollTrigger.scrollTo tween or plugin.function getScrollPosition(animation, progress) {
let p = gsap.utils.clamp(0, 1, progress || 0),
st = animation.scrollTrigger,
containerAnimation = st.vars.containerAnimation;
if (containerAnimation) {
let time = st.start + (st.end - st.start) * p;
st = containerAnimation.scrollTrigger;
return st.start + (st.end - st.start) * (time / containerAnimation.duration());
}
return st.start + (st.end - st.start) * p;
}
start/end scroll bounds directly.