Jump to content
Search Community

Problem with ScollSmoother and Astro View Transitions

Ignatix test
Moderator Tag

Recommended Posts

I know, the idea is a way to enable/disable or destroy/create the ScrollSmoother instance on a route change. My objective is to share that particular approach, give you an idea of how to proceed:

 

import ScrollTrigger from "gsap-trial/ScrollTrigger";
import ScrollSmoother from "gsap-trial/ScrollSmoother";
import {gsap} from "gsap"


gsap.registerPlugin(ScrollTrigger, ScrollSmoother);

const constructScroller = () => {

  ScrollSmoother.create({
    smooth: 1
  })
}

document.addEventListener("astro:page-load", constructScroller)
document.addEventListener("DOMContentLoaded", constructScroller);

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

Yes, I know, the problem I'm facing is exactly that. With viewTransition, it doesn't work, but without it, ScrollSmoother works perfectly. However, viewTransition is an important part of the site's flow and design.

Link to comment
Share on other sites

Are you using that approach in your layout file in astro? In your demo I don't see that.

 

That basically seems to be something Astro is doing behind the scenes. ScrollSmoother works without any issues with Next, Nuxt, SvelteKit and other SSR systems. If with that approach it doesn't work honestly IDK what to tell you.

 

Sorry I can't be of more assistance.

Happy Tweening!

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