I am using gsap scrolltrigger in a nextjs app. I have set up the scroll animation and everything is working except the numerical scrub value has no effect. No matter what number I put in, it acts as if it was just scrub: true.
Here is how I've set it up. In my main page:
import { useRef } from 'react'
import { gsap } from 'gsap'
import { useGSAP } from '@gsap/react'
import { ScrollTrigger } from 'gsap/ScrollTrigger'
import { ScrollToPlugin } from 'gsap/ScrollToPlugin'
import { introAnimation, masterScroll } from '@/animations'
const scope = useRef<HTMLElement>(null)
const tl = useRef<gsap.core.Timeline>()
useGSAP(
() => {
gsap.registerPlugin(ScrollTrigger, ScrollToPlugin)
tl.current = gsap
.timeline()
.add(introAnimation())
.eventCallback('onComplete', () => {
masterScroll(scope)
})
},
{ scope: scope }
)
return (
<main ref={scope}>
...
</main>
)
Then in animations.ts:
import { gsap } from 'gsap'
import { RefObject } from 'react'
export const masterScroll = (trigger: RefObject<HTMLElement>) => {
const tl = gsap.timeline({
scrollTrigger: {
trigger: trigger.current,
start: 'top top',
end: '+=900%',
scrub: 1,
pin: true,
},
})
// tl. animations
return tl
}
The scroll animations are working, but the scrub value has no effect. There is no smoothing whatsoever. What am I missing?