矢印ボタンをクリックすると、ウィンドウが次の要素にスクロールしますが、下にスクロールしてランダムな要素をクリックすると、最初に前にクリックした要素に戻るか、クリックしない場合は次の要素に移動します。最初の要素。
現在クリックされている要素の横にスクロールしたい。すべてが泡立っています。
私が取り組んでいる、状況が現れるサイト-http://dawidjarzabek.pl/test
jQuery:
var currentElement = $(".post");
$('.post #nav a.prev').click(function() {
currentElement = currentElement.prev();
$.scrollTo(currentElement, 800);
});
$('.post #nav a.next').click(function() {
currentElement = currentElement.next();
$.scrollTo(currentElement, 800);
});
HTML:
<div id="1" class="section">
<div class="post position">
<div id="photo"><center><img src="photos/studio/1.jpg" /></center></div>
<div id="nav"><a class="prev"><img src="images/icon_top.png" /></a><a class="next"><img src="images/icon_bottom.png" /></a></div>
<div id="text">
<h1>Modelka: </h1>
<h2></h2>
<h1>Wizaż : </h1>
<h2></h2>
</div>
</div>
<div class="post position">
<div id="photo"><center><img src="photos/studio/2.jpg" /></center></div>
<div id="nav"><a class="prev"><img src="images/icon_top.png" /></a><a class="next"><img src="images/icon_bottom.png" /></a></div>
<div id="text">
<h1>Modelka: </h1>
<h2></h2>
<h1>Wizaż : </h1>
<h2></h2>
</div>
</div>
</div>
[the rest .post and .section]