nuxt / movies

🍿 A TMDB client built with Nuxt 3
https://movies.nuxt.space
MIT License
2k stars 284 forks source link

fix: remeber scroll position when go to previous page, resolve #16 #31

Closed ali4zimi closed 1 year ago

ali4zimi commented 1 year ago

I used localstorage to store previous pages with their scroll position. When the user presses the back button they will be at the same location where they left off. I worked on this solution today and it works now. Please check it once more

atinux commented 1 year ago

Thanks @ali4zimi

Why using the localStorage since the navigation is on client-side actually, why not using a variable in memory instead?

ali4zimi commented 1 year ago

Thanks, @Atinux for reviewing it, I assumed when the user refreshes on the next page, the variable in the memory would be cleared.

atinux commented 1 year ago

If he refreshed the browser will respect the position normally.

antfu commented 1 year ago

I actually wrote a library with @posva about this yesterday coincidentally https://github.com/antfu/vue-router-better-scroller

antfu commented 1 year ago

Thank you! Please check https://github.com/nuxt/movies/commit/83d466e54794ffa20ba14ae54526c0278e656fdb instead.

ali4zimi commented 1 year ago

Thanks, great library! I needed this for one of my own projects.