Jump to content
Search Community

Recommended Posts

Abox Agency
Posted

I have added smooth scrolling in the layout page of my Next.js project, but I’m facing an issue. When I go to the footer and click on the About navigation link, the page opens, but it appears blank. Only after scrolling does the content become visible. Also, when I navigate from the About page to the Home page, it doesn’t start from the top it starts from somewhere in the middle, and only after scrolling does it go back to the top.

open this link and show my issue "http://185.131.54.91:8002"

See the Pen by (@) on CodePen.

GSAP Helper
Posted

Without a minimal demo, it's very difficult to troubleshoot; the issue could be caused by CSS, markup, a third party library, a 3rd party script, etc. Would you please provide a very simple CodePen or Stackblitz that illustrates the issue? 

 

Please don't include your whole project. Just some colored <div> elements and the GSAP code is best. See if you can recreate the issue with as few dependencies as possible. Start minimal and then incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, at least we have a reduced test case which greatly increases your chances of getting a relevant answer.

 

See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen.

that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

 

Using a framework/library like React, Vue, Next, etc.? 

CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import GSAP as shown in the Install Helper in our Learning Center : 

 

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. 

Posted

Hi,

 

This is most likely tied to something else in your app. I create a simple Next app using a similar approach and I can't seem to replicate the issue you're having:

https://codesandbox.io/p/devbox/vqc3f2

 

That basically tells me that there is nothing related to either GSAP or ScrollSmoother that is causing this, but perhaps other package/plugin you're using which is causing the problem. Unfortunately we don't have the time resources to comb through an entire codebase in order to look and fix an issue for our users, is beyond the scope of the help we provide in these free forums.

 

For the hero section rendering issue, try removing/turning-off any plugin you might be using in it in order to see if that helps.

 

For the scroll position, Next's Link component has a scroll restoration prop:

https://nextjs.org/docs/app/api-reference/components/link#scroll

 

You can use ScrollTrigger's clearScrollMemory method as well:

https://gsap.com/docs/v3/Plugins/ScrollTrigger/static.clearScrollMemory()

 

Hopefully this helps

Happy Tweening!

Posted

I forgot, look if Tailwind is adding some CSS transitions to the smooth-content element or the <html> tag, since that could lead to some issues (the scroll position one most likely). If so be sure to override them using this custom CSS:

html {
  scroll-behavior: auto !important;
}

#smoot-content {
  transition: unset !important;
}

Happy Tweening!

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...