created scrollToPage function.