-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ScrollSmoother Usage #8
Comments
Hi @davidkhierl Can you please provide a minimal demo (like a Stackblitz) that clearly illustrates the issue? Here's a starter file you can fork: https://stackblitz.com/edit/react-iqmjfx?file=src%2FApp.js It seems like you've got logic in there that would cause it to render without any smooth-wrapper or smooth-content if noInitialWrapper is truthy. Might that be your problem? I also noticed that you didn't register the useGSAP hook as a plugin before using it, like: gsap.registerPlugin(useGSAP); Once we see a minimal demo, I'm sure things will become much more clear. You might want to consider posting your question/demo in the forums at https://gsap.com/community |
Hi @jackdoyle I'm using nextjs, I believe its because of the SSR, I moved the gsap.registerPlugin(ScrollTrigger, ScrollSmoother)
export const ScrollSmootherWrapper = forwardRef<
HTMLDivElement,
HTMLAttributes<HTMLDivElement>
>(({ children, ...props }, ref) => {
useGSAP(() => {
ScrollSmoother.create({
wrapper: '#smooth-wrapper',
content: '#smooth-content',
smooth: 2,
effects: true,
})
})
return (
<div ref={ref} id="smooth-wrapper" {...props}>
<div id="smooth-content">{children}</div>
</div>
)
}) and added <body suppressHydrationWarning></body> I hope this is some of the right way to use in NextJS> For the registering of useGsap, I don't find it on the documentation is it required also to register it? |
Hi @davidkhierl! We have this demo that shows how to use ScrollSmoother in a NextJS app, using the app router:
Is not really necessary to register the hook but it could be needed if you're testing things with the GSAP Trial package, since the GSAP object being imported in the useGSAP would be a different one than the one imported from the GSAP Trial package:
The As I mentioned is not really needed but it doesn't hurt in any way to register it.
Right now we're looking into a way to avoid the SSR warnings while registering and using GSAP and our Plugins. I hope to have a working demo between today and tomorrow. |
@rhernandog Hi, we currently using gsap business license. Before I fixed the hydration error by moving the Following the above, by putting the before I will also try to create a simple demo with |
エラー文: A tree hydrated but some attributes of the server rendered HTML didn't match the client properties. This won't be patched up. This can happen if a SSR-ed Client Component used: 参考: greensock/react#8 https://gsap.com/community/forums/topic/35440-warning-extra-attributes-from-the-server-style/#comment-203599 → run into similar issue using the app directory in NextJS 13. I'm using ScrollTrigger and ScrollSmoother plugin and managed to fix it by moving the gsap.registerPlugin(ScrollTrigger, ScrollSmoother) inside of useEffect/ useIsomorphicLayoutEffect hook.
Maybe we can add documentation on how to use with
ScrollSmoother
?here is my current implementation but it seems the
smooth
doesn't worksand I have this in one of my component
The text was updated successfully, but these errors were encountered: