1

Imaging a page (vertical scrollable) full of thumbnails of images. When clicking on a thumbnail the image opens in fullscreen. It has a <Link /> which leads back to the thumbnail page. Currently this leads to the top of the thumbnail page.

How can I instead link to the last scroll position?

ynotu.
  • 1,091
  • 1
  • 14
  • 35

1 Answers1

2

As you know which thumbnail you just displayed, you could set an id on them, and when you click back to the thumbnail page, you can make the page scroll to the position of the last displayed id/image.

ChrisR
  • 3,504
  • 1
  • 13
  • 22
  • Thanks for the hint! Im using document.getElementById(id).scrollIntoView() in componentDidUpdate() now. Tricky thing is, I have to use a setTimeout() to delay the call otherwise it would not scroll. – ynotu. May 03 '18 at 18:39