Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create thumbnail carousel with image previews in Slick.js?

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:

capture

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.

like image 564
Ave Avatar asked Sep 19 '16 07:09

Ave


2 Answers

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: enter image description here

like image 181
Pravesh Agrawal Avatar answered Oct 18 '22 15:10

Pravesh Agrawal


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;
}
like image 24
Fandi Susanto Avatar answered Oct 18 '22 14:10

Fandi Susanto