cx20012002 Posted September 7, 2023 Posted September 7, 2023 Hi GSAP I'm facing a new issue to make the scrolltrigger working properly in next js 13.4 when switch between pages, I have done 2 pages with gsap and scrolltrigger in next js (home page, about page), there is no issues if i just visit one of the page, if i go to home page first then about page, and then scroll further down in about page, and then redirect back the home page again, the problem happended, it looks like the scrolltrigger positions were all incorrect, it seems like not been cleaned properly. I have been search online for the solution, and try to use gsap context to wrap all the animation and scrolltriggers, then return to clean with context revert function as recommended from the offical website, i also put ScrollTrigger.refresh() to reset its positions or animations, after i use ScrollTrigger.refresh(), everything works perfectly in dev mode, no problems when i'm swtich between the pages, it aways reset the scrolltrigger to act correctly, but ScrollTrigger.refresh() not working when i deploy with production mode, i tried everything and could not work it out, it is a bit hard for me to put the code into Codepen as it's a project with routes and dependencies and paths...., so i just attach a image of my gsap code for you as an reference, also a link of the website deployed on vercel Create Next App (next-cv-psi.vercel.app)
cx20012002 Posted September 7, 2023 Author Posted September 7, 2023 I added a line of code on the top window.scrollTo(0,0), this fix the issue, but i think gsap must have its own way to deal with the reset, looking forward to your reply
GreenSock Posted September 7, 2023 Posted September 7, 2023 First of all, nice job on the site. It looks sharp. ? It's super difficult to troubleshoot by just looking at a screenshot, and we can't diagnose issues on a live website, but if you'd like more help please make sure you provide a minimal demo. No need to use CodePen - you can use this Next Starter Template Please share the StackBlitz link directly to the file in question (where you've put the GSAP code) so we don't need to hunt through all the files. Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions.
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