Skip to content
Advertisement

Using the duration of mouse press for scrolling

I coded this:

JavaScript
JavaScript
JavaScript

You need to click the buttons pretty often to navigate through this container. Is there a way to let it based on the duration of the mouse press? Like if you keep the mouse pressed, it continues constantly scrolling? And if you stop, it stops.

Would be happy if someone could help me.

Advertisement

Answer

Here’s a working solution. Also your code was a bit wet, so I refactored it a bit. You only need one mousedown event listener.

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement