Closed rubenvangrins closed 3 months ago
Since Lenis doesn't affect your scroll position on page change, i guess that's a Next.js issue. Please be sure this behaviour occurs only when Lenis is applied.
I've updated my lenis package and not it works..
Description
My horizontal website built with Next.js 14.1.2 does not reset the scroll position when changing routes. I want the scroll position to reset on route changes but also to maintain the scroll position when the user clicks the browser's back button.
Components Involved
Scroll Component:
Template Component:
RootLayout Component:
Page Component:
Issue Details
style={{ display: 'flex', width: 'fit-content' }}
fromPage.tsx
, the scroll position resets correctly on route change.Template.tsx
and used for wrapping child components.Steps to Reproduce
Page.tsx
.Expected Behavior
The scroll position should reset to the left when navigating to a new route but should maintain the position when the user navigates back using the browser's back button.