stutrek/scrollmonitor

Refreshing page and loading into the middle causes all the numbers to be wrong.

Closed this issue · 1 comments

I have a listener looking for { top: 0, bottom: -60 } which works just fine if the page loads all the way at scrollY = 0; but if you're half way down the page.. press refresh.. and Chrome puts you back there, all the numbers are wrong. It assumes the starting position is where you want to be, not the fact you're already half way down the page.

Turns out this happens when you use "body" in the createContainer method. We were using a different container at first, but later changed to scrolling with the body. Instead of using scrollMonitor.create(...) we were using container.create(...) where the container = document.querySelector('body') from a flexibility standpoint.

This seemed to be the cause of the issues. Using scrollMonitor.create(...) for body scroll worked as expected.