jQuery:ナビゲーションにいる場所に基づいて、どうすればさまざまな効果がありますか
-
04-10-2019 - |
質問
私はこれを持っています:
$('#mask').cycle({
fx: 'scrollLeft',
timeout: 0,
speed: 300,
startingSlide: 0
});
しかし、FXをスクロールアップにしたい特定のケースがあります(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
});
}
所属していません StackOverflow