View Single Post
Old 06-11-2012, 08:50 PM   PM User | #1
kristinachilds
New to the CF scene

 
Join Date: Jun 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
kristinachilds is an unknown quantity at this point
Question conditional background position link based on current position

I have a script that works great except one small problem. It's easiest to explain with visual aid http://avalon.eaw.com/#finishes

this uses the background position property to animate the color changes. the only problem is that the "horn" options are hard-coded such that if you are currently viewing a speaker that has white cab with a colored horn and want to change the cabinet to black, it changes the horn to black as well. there is no way currently to view a black cab with colored horn.

to fix it i need to make a conditional statement but am not sure how to make it work. something like:

Code:
function colorChange() {
    $("#target").css('background-position', xposition+'px '+yposition+'px');
    if $("#target").css('background-position') == {x:-754} {
        updatePositions({x:-377});
    } else if $("#target").css('background-position') == {x:-377} {
        updatePositions({x:-754});
    }
}
i'm very new to javascript so please be gentle
kristinachilds is offline   Reply With Quote