Angular Scroll Position Restoration

Опубликовано: 15 Октябрь 2024
на канале: Code Shots With Profanis
6,326
205

In Angular, you can customize the scrolling behavior by using the withInMemoryScrolling. While this works great, it has a pitfall when introducing a delay in the response of the data.

In this video, you will learn how to create a reusable and easy-to-use approach to restore the scrolling position when a user navigates back to a list of items

Chapters:
00:00 Intro
00:29 Enable the withInMemoryScrolling
02:28 How things work
03:38 Restore Scrolling Position having an HTTP delay
10:17 Refactor the code to make it reusable
15:12 Thank you

✨ Code: https://github.com/profanis/codeShots...

✨ Credits
[Ryan Hutchison] Who put me on the right track, and told me that there is no need for an additional state layer since Angular already keeps the scrolling position on the router state.

******************************************************
Let's connect
******************************************************
Twitter:   / prodromouf  
LinkedIn:   / prodromouf  

#angular #learnAngular #angularTutorial #webdeveloper #angulartraining #webdevelopment