I can't seem to get this working.
$('#product_family_options_dd').animate({
height: '300px',
width: '900px',
backgroundPosition: '-20px 0px',
},
The height and width animate but not the background.
I can't seem to get this working.
$('#product_family_options_dd').animate({
height: '300px',
width: '900px',
backgroundPosition: '-20px 0px',
},
The height and width animate but not the background.
I guess it might be because it is expecting a single value?
taken from the animate page on jQuery:
Animation Properties and Values
All animated properties should be animated to a single numeric value, except as noted below; most properties that are non-numeric cannot be animated using basic jQuery functionality. (For example, width, height, or left can be animated but background-color cannot be.) Property values are treated as a number of pixels unless otherwise specified. The units em and % can be specified where applicable.
This returns [x] value. Length of number has no matter. Could be e.g. 9999 or 0.
You can change the image background position using setInterval method, see demo here: http://jquerydemo.com/demo/animate-background-image.aspx
jQuery's animate function is not exclusively usable for directly animating properties of DOM-objects. You can also tween variables and use the step function to get the variables for every step of the tween.
For example, to animate a background-position from background-position(0px 0px) to background-position(100px 500px) you can do this:
Just make sure to not forget the this. inside the step function.
You can also use math combination "-=" to move background
You don't need to use the background animate plugin if you just use separate values like this: