question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slider in infinite mode not creating clones when slidesToShow === slideCount

See original GitHub issue

Expected behavoir: when initial code looks like this:

<div id="slider">
  <div>1</div>
  <div>2</div>
  <div>3</div>
</div>
<script>
  $('#slider').slick({ slidesToShow: 3, slidesToScroll: 1 });
</script>

then generated code should look like this:

<div id="slider">
  <div class="slick-cloned">1</div>
  <div class="slick-cloned">2</div>
  <div class="slick-cloned">3</div>
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div class="slick-cloned">1</div>
  <div class="slick-cloned">2</div>
  <div class="slick-cloned">3</div>
</div>

currently there are none of slick-cloned elements generated if slidesToShow === slideCount

my dirty fix was to replace this _.slideCount > _.options.slidesToShow with _.slideCount >= _.options.slidesToShow which fixes my issue … but i would prefer correct fix …

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:7

github_iconTop GitHub Comments

3reactions
YuanWenqingcommented, Apr 16, 2021

We had a similar issue like this: if slideCount <= slidesToShow and initialSlide > 0, all slides before initialSlide will be hidden.

Actually we can accept that no cloned slides is generated in this situation, but it’s really a big problem that some slides are hidden. The reason is the incorret value of transform in style of slick-track element.

We do a tricky hotfix:

  function fixSlickStyle(event, slick) {
    if (slick.slideCount <= slick.options.slidesToShow) {
      slick.$slideTrack.css('transform','');
    }
  }

  $('.slider-class')
  .on('setPosition', function(event, slick) {
    fixSlickStyle(event, slick);
  })
  .on('afterChange', function(event, slick, currentSlide){
    fixSlickStyle(event, slick);
  })
2reactions
jaimerportmanncommented, Jul 23, 2020

you cannot set the slide with or max-width, I removed that and fixed it. as the slider defines the width of each slide

Read more comments on GitHub >

github_iconTop Results From Across the Web

Force cloning slides in slick - Stack Overflow
In my case I have a slider with filters, when the filtered elements are the same as the elements to be displayed, the...
Read more >
Options - Splide
Explicitly determines the number of clones on each side of the carousel ... Determines how many pages (not slides) around the active slide...
Read more >
Untitled
slider .children( _.options.slide + ':not(.slick-cloned)') .addClass('slick-slide'); _.slideCount = _.$slides.length; _.$slides.each(function(index, ...
Read more >
Slick Slider Example - CodePen
Here's an example of an image carousel using Slick Slider. This example has a couple breakpoints to illustrate it's responsiveness....
Read more >
React Slick Doesn't Loop Slides If Slidestoshow Is Equal to the ...
Slider in infinite mode not creating clones when slidesToShow slideCount.Original URL.Expected behavoir: when initial code looks like this:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found