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.

Reinit slider when leaving a breakpoint with settings: 'unslick'

See original GitHub issue

Hey there, really love your plugin, I use it in nearly every project – thanks for the great work. I observed a counter-intuitive behaviour with the following init code:

    var slickBaseSettings = {
        infinite: false,
        slide: '.is-slide',
        adaptiveHeight: true,
        dots: false,
        slidesToShow: 4, 
        arrows: true
    };
    $('.is-slider').slick( $.extend({
        responsive: [{
            breakpoint: 640,
            settings: 'unslick'
        }]
    }, slickBaseSettings) );

One would expect that once leaving the breakpoint the slider reinitializes but it is not the case. Am I missing something?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8

github_iconTop GitHub Comments

18reactions
romannikiforovcommented, Dec 7, 2018
const settings = {
     // default settings
    responsive: [
        {
            breakpoint: 900,
            settings: { slidesToShow: 3 }
        },
        {
            breakpoint: 600,
            settings: { slidesToShow: 2 }
        },
        {
            breakpoint: 420,
            settings: "unslick"
        }
    ]
};

const sl =  $('.slider').slick(settings);
      
$(window).on('resize', function() {
   if( $(window).width() > 420 &&  !sl.hasClass('slick-initialized')) {
         $('.slider').slick(settings);
    }
});
9reactions
stevegrunwellcommented, Mar 7, 2017

For those who stumble across this issue through Google, I did a writeup on my company’s blog demonstrating how to cleanly re-initialize Slick carousel in a responsive setting, after destroying it via unslick.

Hopefully this helps someone else 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Responsive breakpoints not working for slick slider
@ntgCleaner Slider doesn't break after I resize the browser. It works fine but that settings doesn't work. If I reload the page at...
Read more >
how to resize slick and unslick - CodePen
Resize the browser to see it working. An example showing how to start and stop slick responsible, like the "unslick" property but re-slicking...
Read more >
58edf23342d377302ce104e59fb...
Set settings to "unslick" instead of an object to disable slick at a given ... rtl, boolean, false, Change the slider's direction to...
Read more >
https://www.aamu.edu/_resources/ldp/galleries/slic...
Enables settings at given `breakpoint`. Set `settings` to "unslick" instead of an object to disable slick at a given breakpoint. rows | int...
Read more >
slick - the last carousel you'll ever need - Ken Wheeler
slick is a responsive carousel jQuery plugin that supports multiple breakpoints, CSS3 transitions, touch events/swiping & much more!
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