I've been utilizing the scrollRestoration
functionality within Next.js to save and restore the page position whenever a user navigates using the back button. However, I've encountered an issue with it not restoring the horizontal scroll position of carousels on the page. To address this, I've implemented custom session variables to track and restore the individual carousel positions upon page reload. The challenge now is determining when to trigger the restoration process - ideally, I only want to restore these scroll positions if the backward/forward navigation buttons were used. It would be helpful if there was some sort of indicator that could signal when scrollRestoration
was employed or detect when the page was visited via the forward/back buttons.
Any suggestions or insights?