I want to preview image after the click to a thumbnail in a slideshow. It also appears image previews in Slick.js. You can see more at here.
Like this:
When a user clicks a thumbnail it will show this image preview.
I watch all demo of Slick but not found any example like this.
You can use Slider Syncing as given here
$('.slider-for').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
fade: true,
asNavFor: '.slider-nav'
});
$('.slider-nav').slick({
slidesToShow: 3,
slidesToScroll: 1,
asNavFor: '.slider-for',
dots: true,
centerMode: true,
focusOnSelect: true
});
It looks like:
I use jQuery index()
plus Slick slickGoTo method
.
Fiddle at: https://jsfiddle.net/beluluk/uh8bpokb/
Html:
<div class='slider'>
<div>Slide 1</div>
<div>Slide 2</div>
<div>Slide 3</div>
<div>Slide 4</div>
<div>Slide 5</div>
</div>
<div class='slider-nav'>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
JS:
//Slick slider initialize
$('.slider').slick({
arrows:false, dots: false, infinite:true, speed:500,
autoplay:true, autoplaySpeed: 3000, slidesToShow:1, slidesToScroll:1
});
//On click of slider-nav childern,
//Slick slider navigate to the respective index.
$('.slider-nav > div').click(function() {
$('.slider').slick('slickGoTo',$(this).index());
})
CSS Beautification:
/*Slider*/
.slider > div {
display:block; width:100%; padding: 50px 0;
background: #FF0;
text-align: center; font-size: 2em;
}
/* Navigation */
.slider-nav { text-align: center; }
.slider-nav > div {
display:inline-block;
width:30px; height: 30px; margin: 0 5px; padding: 3px 0;
text-align: center; font-size:2em;
background: #FC0; cursor: pointer;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With