0

I use this to scroll animate a page.

if (e.keyCode == 38)  
$('div').animate({scrollTop:"-=50"},'5000', 'linear')
if (e.keyCode == 40)  
$('div').animate({scrollTop:"+=50"},'5000', 'linear')

but I have to press and hold up or down arrow key to continuously animate. How can I make it to start animation on one press then increase speed when the same key (up or down) is pressed again

Thanks

Tony Cronin
  • 1,623
  • 1
  • 24
  • 30
Wayne
  • 763
  • 4
  • 21
  • 43

1 Answers1

0

As this, you can add another if clause that detects if it is animating or not. If it is animating, stop the current animation and start another with a faster speed.

I think an integer regarding how many times it has been animated would be nice, as the speed could be 50*THAT_INTEGER.

Community
  • 1
  • 1
hawaii
  • 328
  • 4
  • 12