I’m coding up a page where I only want to use raw JavaScript code for UI without any interference of plugins or frameworks.
And now I’m struggling with finding a way to scroll over the page smoothly without jQuery.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this smooth scrolling demo, or an algorithm like:
self.pageYOffsetelement.offsetTopwindow.scrollToSee also the other popular answer to this question.
Andrew Johnson’s original code:
Related links: