This is my html code:
<div class="profile-gallery">
<div class="profile-gallery_top js-bigImg">
<a href="img/bigImg1.jpg" class="swipebox">
<img class="profile-bigImage" src="img/bigImg.jpg" alt=""/>
</a>
</div>
<ul class="profile-thumbs">
<li><img src="img/imgThmubs1.jpg" data-bigimage="img/bigImg1.jpg" data-original="img/origImg1.jpg" alt=""/></li>
<li><img src="img/imgThmubs2.jpg" data-bigimage="img/bigImg2.jpg" data-original="img/origImg2.jpg" alt=""/></li>
<li><img src="img/imgThmubs3.jpg" data-bigimage="img/bigImg3.jpg" data-original="img/origImg3.jpg" alt=""/></li>
</ul>
</div>
I have big image and under big image there are 3 thumbnails. If user click second thumbnail, big image has to changes to second data-bigimage. And swipebox link has to change to second data-original image. The same for other images.
This is solution for switching images:
jQuery(document).ready(function( $ ) {
$('.profile-thumbs li').click(function(){
var imageurl = $(this).children('img').data('bigimage');
var imageorig = $(this).children('img').data('original');
$('.profile-bigImage').attr("src", imageurl);
$('.swipebox').attr("href", imageorig);
});
});
Here is the code which pushes images into swipebox array:
$(function () {
new App();
$('.swipebox').click(function(e) {
$.swipebox(imgs());
e.preventDefault();
});
function imgs() {
var th = $('.profile-thumbs li');
var arr = [];
for(var i = 0; i < th.length; i++) {
var obj = {};
var current = $(th[i]).find('img').attr('data-original');
obj['href'] = current;
arr.push(obj);
}
return arr;
}
});
The problem is that Swipebox gallery always starting swipe from first image. How can I change above code, that it shell swipe from selected image?