I have two divs and two buttons:
<div id="container">
<div id="items"></div>
</div>
<div id="up"></div>
<div id="down"></div>
How to continuously scroll '#items' until user releases the button? I tried using jquery mousedown event and animate function but couldn't make it to work.
$("#up").mousedown(function(){
$("#items").animate({"top": "+=10px"}, "fast");
})
The code above moves the div just once. I want to achieve continuous animation until the button is released. Thanks for your help!
I've improved @jesse-dupuy's fiddle. I've added the 'linear' easing to the animation so the scroll is smooth and moved the .on('mouseup') event from the button to the document so it doesn't matter where the user releases the mouse button.
My fork on JSFiddle: https://jsfiddle.net/ferares/9mw598hd/7/
Please, try this: