jQuery: how do I have different effects based on where you are in navigation
I h开发者_StackOverflowave 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?
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";
}
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
});
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
});
}
精彩评论