Jump to content
Search Community

smoothScroll and Astro.js

chester test
Moderator Tag

Recommended Posts

Hi, I'm trying out for my local project in Astro (https://astro.build/) how smoothScroll works, unfortunately after connecting the script, I tried directly attaching from cdn (https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/ScrollSmoother.min.js) or downloading and attaching the file and I get an error: Uncaught TypeError: Cannot set property window of #<Window> which has only a getter

I don't know how to deal with this, is there a solution? The gsap itself works without a problem.

Screenshot 2023-10-29 at 19.14.31.png

Link to comment
Share on other sites

It's very difficult to troubleshoot without a minimal demo, but my guess is that maybe you didn't register the plugin?

gsap.registerPlugin(ScrollTrigger, ScrollSmoother)

And make sure you do that when the window and document exist. Some SSR frameworks run things twice - once on the server (when there's no window or document yet) and then again in the browser. You should only run the GSAP-related code in the browser (when window and document objects exist). 

 

If you still need help, please make sure you provide a minimal demo. There are a bunch of starter templates at https://gsap.com/demos

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...