What happened to the bit where you moved these out of the `onscroll` function?