Keep scrollPosition
Unanswered
oliver posted this in #help-forum
oliverOP
I am developing blog website and there is one problem to implement back logic. There is blog list page and I implemented infinite scroll there so that users can explore blogs using scroll. So users can move to blog detail page in this blog list page and I have to add back button to blog detail page. In this back logic, scroll position of the blog list page should be kept. So I implemented it using
Are there any good way to implement it correctly?
router.back function but in this case, the scroll will go down and not keep the previous position.Are there any good way to implement it correctly?
5 Replies
Knopper gall
You can update the URL with the ID of the middle-most element
http://my.link/page#elementId
This will scroll you to the element on reload
http://my.link/page#elementId
This will scroll you to the element on reload
Not sure if that's the 'best' way though
oliverOP
In that case, it will scroll to the top of that blog, but I wanna keep the exact same position
@oliver In that case, it will scroll to the top of that blog, but I wanna keep the exact same position
Knopper gall
I guess you could store raw scroll y in the url as a parameter but that's just dirty.
Otherwise ID specific points in your app
Otherwise ID specific points in your app
I'd be interested to hear other suggestions