skyfy Posted April 30, 2021 Share Posted April 30, 2021 Hello, I must be missing something in this code, how can I set default values to have no animation on every load. Currently my header slides down on every page load. Any suggestions would great appreciated. useEffect(() => { if (typeof window !== `undefined`) { gsap.registerPlugin(ScrollTrigger) gsap.core.globals('ScrollTrigger', ScrollTrigger) } const showAnim = gsap .from(headerRef.current, { yPercent: -100, paused: true, duration: 1, }) .progress(1) ScrollTrigger.create({ id: 'navbar', start: 'top top', end: 99999, // scrub: true, onUpdate: self => { return self.direction === -1 ? showAnim.play() : showAnim.reverse() }, }) return () => {} }, []) Link to comment Share on other sites More sharing options...
GreenSock Posted April 30, 2021 Share Posted April 30, 2021 I don't quite understand the question. Can you please provide a minimal demo? And are you saying that when the page loads you want nothing to happen...but when the user starts scrolling forward (down the page) you want showAnim.reverse() to get called, but when the user scrolls backward, showAnim.play() gets called? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now