1

Is there a Javascript event that I can hook into that fires when the page is refreshed, and Safari 'jumps' back to the scroll position you were at?

It's very frustrating, as the scroll event only fires on user/touch-induced scrolls, so will not fire in this case. I need to specifically find a way to bind to that event, as DOMContentLoaded, for example, fires even before that, and the window's load event would fire too late, as that will wait for all content to load.

Reason for this is that I am checking if an element is in view (using getBoundingClientRect).

Am I missing something here? As I'm not using jQuery, but vanilla JS, I have no document.ready() to try (though judging by the source code of it, I doubt it would work).

Community
  • 1
  • 1
c_kick
  • 1,408
  • 10
  • 17

1 Answers1

1

After some experimenting, it turns out that the load /onload event on the window triggers this jump in Safari Mobile (and presumably other browsers too), so binding to that event would suffice.

I hope this helps someone!

c_kick
  • 1,408
  • 10
  • 17
  • It doesn't seem correct, at least this is not what I saw. It looks setting initial scroll position doesn't correlate with load event and can occur after it. – Anton Zhdanov Jun 03 '17 at 07:57