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

2

11

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.

Strickler answered 19/9, 2016 at 7:12 Comment(0)
C
34

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

Commonality answered 19/9, 2016 at 7:24 Comment(1)
That great. I really don't see this until your comment. Thank you very much.Strickler
H
13

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;
}
Homeland answered 7/4, 2018 at 10:38 Comment(1)
This makes sense if they number of slides is changing, instead of using Slide Syncing.Planospore

© 2022 - 2024 — McMap. All rights reserved.