michaeljscript / next-restore-scroll-position

Restore scroll position using NextJS
14 stars 2 forks source link

Support for scroll restoration within a specified scroll container id #2

Open shawnCaza opened 1 year ago

shawnCaza commented 1 year ago

Some CSS techniques may limit scrolling within a specific div, rather than allowing the normal window level scrolling. In order to handle scroll restoration within such a scenario, an optional 'scrollAreaId' parameter is added to useScrollRestoration. If the parameter is set, and a div with that ID is found, then the scroll position of the specified div is saved/restored as needed.