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.

Why is slick adding slick-cloned slides to my slider?

See original GitHub issue

Hi,

I have setup a slider with the correct js and markup as below:

<div class="books-slider">
        <% @books.shuffle.each do |book| %>
            <div class="slide <%= book.age %> <%= book.story_types.map(&:inspect).join(' ').gsub('"','').downcase %>" data-type="<%= book.story_types.map(&:inspect).join(', ').gsub('"','').downcase %>" data-title="<%= book.title %>" data-age="<%= book.age %>" data-author="<%= book.author.name %>">
              <%= link_to(book) do %>
                <div class="in">
                  <div class="book-jacket">
                    <%= image_tag book.jacket_cover.url %>
                  </div>
                </div>
              <% end %>
              <% if user_signed_in? %><%= link_to 'Destroy', book, method: :delete, style:'top: 0px;position: absolute;', data: { confirm: 'Are you sure?' } %><% end %>
              </div>
        <% end %>
      </div>

The above code basically runs through a loop and generates the slides from the loop and adds to them. Then I have the js that initiates the slider and gets data and inputs certain html in the slider:

$('.books-slider').slick({
                centerMode: true,
                centerPadding: '20px',
                slidesToShow: 1,
                adaptiveHeight: true,
                variableWidth: true,
                prevArrow: '.arrow-left',
                nextArrow: '.arrow-right',
                onInit: function(slide,index) {
                    var cr = $(slide.$slides.get(index));
                    var initTitle = cr.data('title'), 
                    initAuthor = cr.data('author'), 
                    initAge = cr.data('age'),
                    initType = cr.data('type');
                    $('.title-highlight h2.title').html(initTitle);
                    $('.title-highlight h2.author').html(initAuthor);
                    $('.title-highlight h2.age').html('Age: ' + initAge);
                    $('.title-highlight h2.type').html(initType);
                },
                onAfterChange: function(slide,index) {
                    var cr = $(slide.$slides.get(index));
                    var initTitle = cr.data('title'), 
                    initAuthor = cr.data('author'), 
                    initAge = cr.data('age'),
                    initType = cr.data('type');
                    $('.title-highlight h2.title').html(initTitle);
                    $('.title-highlight h2.author').html(initAuthor);
                    $('.title-highlight h2.age').html('Age: ' + initAge);
                    $('.title-highlight h2.type').html(initType);
                },
                responsive: [
                {
                  breakpoint: 768,
                  settings: {
                    arrows: false,
                    centerMode: true,
                    centerPadding: '40px',
                    slidesToShow: 3
                  }
                },
                {
                  breakpoint: 480,
                  settings: {
                    arrows: false,
                    centerMode: true,
                    centerPadding: '40px',
                    slidesToShow: 1
                  }
                }
                ]
            });

When I load the page I see that the slides have been cloned. There are only meant to be 2 at this current moment.

Here is what I see in the inspector:

screen shot 2015-01-20 at 16 10 28

Can anyone please help me here?

Thanks

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:7
  • Comments:30

github_iconTop GitHub Comments

87reactions
linorabolinicommented, Feb 15, 2016

But what if I want the infinite slideshow but without html clones ?

54reactions
simeydotmecommented, Jan 21, 2015

@mdunbavan thanks for contributing 😊

The cloned items are because you have an infinite carousel with 3 slides to show and in center mode. What this means is that Slick needs to place “clones” of those slides at each end of the carousel so that when you approach the end it has a copy to display at the beginning as it “infinitely” goes around.


Curiously; what exactly is your problem, and what is the bug with the plugin which you are creating an issue for? 😄 – if none please kindly close the issue.

Regards, Simon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cloning extra slides for Slick Slider - Stack Overflow
I am using jQuery Slick Slider to create a left-aligned, infinite, variable-width slider. Here is the JSFiddle: http://jsfiddle.net/mtaube/rLkj3wcn/2/.
Read more >
slick-cloned?? What is it? - WordPress.org
The .slick-cloned class is there to enable an infinite scrolling carousel. This plugin uses the Slick library to create its carousel.
Read more >
Slick slider and Lightbox2 - remove clones - CodePen
Little script that removes duplicated slides/images in Lightbox2...
Read more >
Solved: AEM Carousel extended to incorporate Slick Slider
The issue it seems is with the clone elements that slick creates. They are incorrectly being captured by the Analytics data layer. Update...
Read more >
Slick Slider - Infinity Loop Current Slide Selected Clone Element
The cloned items are because you have an infinite carousel with 3 slides to show and in center mode. What this means is...
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