fadeIn、アニメーション、CSSのトランジションとトランスフォーメーションにこのコードを使用しました。jQueryスクロールベースのスクロールスクロールを待っていません
$(window).scroll(function(){
$('.item1').each(function (i) {
var bottom_of_object = $(this).offset().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height();
/* For testing only */
console.log(bottom_of_object);
console.log(bottom_of_window);
/* If the object is visible in the window */
if (bottom_of_window > bottom_of_object) {
$(this).fadeIn(1000, 'swing', function() {
$('.item2').fadeIn(1000, 'swing', function() {
$('.item3').fadeIn(1000, 'swing', function() {
$('.item4').fadeIn(1000, 'swing');
});
});
});
}
})
});
しかし、このHTMLでは正しく動作しません。
<div class="container">
<div class="row">
<div class="col-md-3 col-xs-12 img-responsive item item1">
<img src="images/gallery/Brows/brows13.png" />
</div>
<div class="col-md-3 col-xs-12 img-responsive item item2">
<img src="images/gallery/Liner/liner2.png" />
</div>
<div class="col-md-3 col-xs-12 img-responsive item item3">
<img src="images/gallery/Body Ink/BI004.png" />
</div>
<div class="col-md-3 col-xs-12 img-responsive item item4">
<img src="images/gallery/Nails/nails1.png" />
</div>
</div>
</div>
今回は何が間違っているのか分かりません。
すみませんでしたが、私は店が閉まる前にドアを出て急いでいました。画像はフェードインされますが、スクロールではなく、ページの読み込み時に行います。
これはfadeInのチェーンを開始するので、 '.item1''を見つけたいだけですが、それはページの読み込みから始まり、スクロールを無視します。 – Bounce
さて、私はそれを得ました。ページを開始すると、すべての画像が表示されます。いくつかのCSSが欠落している可能性があります。私は、4番目の画像で退色を示すコードを調整しました。 – Gerard
いいえ.item1は '$(document).ready()'でfadeInシーケンスを開始します。しかし、あなたの答えは私にアイデアを与えました。 '.item {表示:なし;}私が持っていた' をちょうど '.item1 {表示:なし;}試してみました' ... '.item4 {表示:なし;}' をそれは – Bounce