Rails infinite pagination needs to remember the previous position when back from another page

I use Kamanari gem

and jQuery infinite scroll

for endless pagination. Everything works fine, but when I go to another page and back to the post list page, then the pagination starts from the first page. Instead of starting the pagination from the first page, it should remember the previous location.
I triedJavaScript History API: pushState and replaceState

update the url to match the scroll position and navigate away from that page and hit the return to browser button. This takes me to the previous scroll positions, scrolling and loading them until I get to the previous scroll position. But it takes too long to scroll and load them. I need me to instantly return to the previous scroll position when I press the browser button, like in mobile Facebook, Twitter and G +.
What's the best solution? How can I achieve this goal?
Thanks in advance.

+3


source to share





All Articles