initial timing code when scrolling up and down