パララックスを表現したくてRellax.jsを使用しているんですが
縦にいくつも画像が並ぶレイアウトで使用したところスクロールを始めると1番下のものも
同じタイミングでパララックスが始まってしまい、画面に出てくる頃には画像はすでに通り過ぎた後で背景が見えてしまう。
いくつ画像が並ぶか決めることはできないので個別に指定はなるべくしたくないのが現状です。
画面内にパララックスさせたい要素が入った時からスタートさせれたらと思っています。
もし何かしらの方法を知っている方がいらっしゃればよろしくお願い致します。
なお、よろしければRellax.jsの設定である
・refresh()
・destroy()
上記2つの使用方法とどのような動きをするのかもわかる方がいればご教授願いたいです。
HTML
1<div class="a"> 2 <a class="b" href=""> 3 <img class="rellax c" src="../public/images/landscape.jpg" alt=""> 4 <div class="d"> 5 <div class="e"> 6 <h2 class="f">sample</h2><p class="g">text</p> 7 </div> 8 </div> 9 </a> 10 </div>
CSS
1.a { 2 position: relative; 3 height: 210px; 4} 5 6.b { 7 position: absolute; 8 display: block; 9 width: 100%; 10 height: 210px; 11 overflow: hidden; 12} 13 14.c { 15 width: 130%; 16} 17 18.d { 19 position: absolute; 20 bottom: 0; 21 width: 100%; 22 height: 50%; 23 background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent); 24} 25 26.e { 27 position: absolute; 28 bottom: 24px; 29 width: 100%; 30 padding: 0 24px; 31 color: #FFF; 32 text-align: center; 33} 34 35.f { 36 font-size: 20px; 37}
script
1var rellax = new Rellax(' .rellax ',{ 2 speed: .4, 3 center: false, 4 //wrapper: '.main', 5 round: true, 6 vertical: true, 7 horizontal: false 8 });
あなたの回答
tips
プレビュー