Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery animate background position in chunks?

I'm trying to use jQuery to make a background position of my span go down 10 pixels every second. What is a good way to do this?

I've been playing with jQuery animate, delay, CSS, and some setTimeout functions but I can't get anything to work. Suggestions greatly appriciated!

I'm trying to make my y-position go from 0 to 100 in increments of 10 pixels, and then stop the animation.

like image 201
sanpall Avatar asked Nov 18 '25 00:11

sanpall


1 Answers

jQuery can't animate background position properly because of the need to animate two values instead of just one. Explanation and solution here:

http://snook.ca/archives/javascript/jquery-bg-image-animations/

like image 195
ghoppe Avatar answered Nov 20 '25 14:11

ghoppe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!