views:

33

answers:

3

I have this:

$('#mask').cycle({ 
    fx: 'scrollLeft',
    timeout: 0, 
    speed:   300, 
    startingSlide: 0 
});

But there is a certain case where I want the fx to be scrollRight lets say when (myCondition == true)

how do I do that?

A: 

This should work..

(myCondition == true) ? _fx = "scrollLeft" : _fx = "scrollRight";

$('#mask').cycle({ 
    fx: _fx,
    timeout: 0, 
    speed:   300, 
    startingSlide: 0 
});

It would be smarter to make an _fx() function, though..

function _fx(c) {
     return (c == true) ? "scrollLeft" : "scrollRight";
}
David Titarenco
A: 

do you mean this:

var myFx = 'scrollLeft';
if( window.location.href.indexOf('myCondition=true') != -1 ) {
    myFx = 'scrollRight';
}

$('#mask').cycle({  
    fx: myFx,
    timeout: 0,  
    speed:   300,  
    startingSlide: 0  
}); 
Here Be Wolves
A: 

I'm going out on a limb and assuming that to scroll right you change fx: to scrollRight. In that case

if(myCondition == true) {
      $('#mask').cycle({
               fx: 'scrollRight',
               timeout: 0,
               speed: 300,
               startingSlide: 0
       });
} else {
      $('#mask').cycle({
               fx: 'scrollLeft',
               timeout: 0,
               speed: 300,
               startingSlide: 0
       });
}
jon3laze