我有这个:

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

但是在某种情况下,我希望FX成为Scrollright,请说何时(mycondition == true)

我怎么做?

有帮助吗?

解决方案

这应该有效..

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

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

做一个 _fx() 功能,不过..

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

其他提示

你的意思是:

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

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

我要肢体出去,假设要滚动你更改 fx: 要滚动。在这种情况下

if(myCondition == true) {
      $('#mask').cycle({
               fx: 'scrollRight',
               timeout: 0,
               speed: 300,
               startingSlide: 0
       });
} else {
      $('#mask').cycle({
               fx: 'scrollLeft',
               timeout: 0,
               speed: 300,
               startingSlide: 0
       });
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top