Domanda

ho questo:

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

Ma c'è un certo caso in cui voglio che il fx di essere scrollRight consente di dire quando (myCondition == true)

Come posso fare?

È stato utile?

Soluzione

Questo dovrebbe funzionare ..

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

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

Sarebbe più intelligente per fare una funzione _fx(), però ..

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

Altri suggerimenti

vuoi dire questo:

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

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

sto andando su un arto e supponendo che per scorrere a destra si cambia fx: a scrollRight. In questo caso

if(myCondition == true) {
      $('#mask').cycle({
               fx: 'scrollRight',
               timeout: 0,
               speed: 300,
               startingSlide: 0
       });
} else {
      $('#mask').cycle({
               fx: 'scrollLeft',
               timeout: 0,
               speed: 300,
               startingSlide: 0
       });
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top