Home > Software engineering >  Can I dynamically change the scroll speed of a website to speed up as the user scrolls further down?
Can I dynamically change the scroll speed of a website to speed up as the user scrolls further down?

Time:12-08

I'm quite new to HTML and hoping to make a prototype of a website where as you scroll further down, the scroll speed increases. Does anyone have any idea how to do this?

CodePudding user response:

Have you tried the following article? How to change the scroll speed of a div

It has an example to help determine if that's something you're looking for. Referencing the article directly so that you can see the code and the solution is appropriately attributed to the author.

CodePudding user response:

You could watch the onscroll event and, depending of the scrollTop and the scroll direction, apply another scrollTop value.

Beware changing scrollTop would trigger the onscroll event again, creating an infinite loop, so you would have to set up a flag like explained here.

  • Related