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.

If content is hidden during Slick bootstrap, Slick refuses to play ball

See original GitHub issue

I’m not sure that this is easily fixable but I’m implementing Slick on a Bootstrap website and I have a Slick-based gallery in a set of Bootstrap tabs. If the gallery tab is the active one on page load, the Slick carousel works fine, but if the gallery tab is not the one that’s active on page load the Slick carousel seems to break (the tab basically looks empty).

At a guess this is due to the items being hidden as Slick is set up against the items and so Slick can’t calculate the dimensions of the slides, etc.

A possible non-Slick-based fix is to hook into BS tab event system and only call $.fx.slick() when the tab is first switched to. Of course this only works for JavaScript components that allow a developer to hook into this kind of event system, so maybe there’s a way for Slick to get round this limitation without requiring developers to do these hackish bits of code (which they sometimes may not be able to do).

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:9
  • Comments:62 (7 by maintainers)

github_iconTop GitHub Comments

81reactions
patrickvaillancourtcommented, Nov 13, 2015

The .resize() option didn’t work for me. I experienced a similar problem attempting to render an embedded google map inside a bootstrap tab as well. To my surprise both problems were resolved by changing how bootstrap handles hidden tabs:

/* bootstrap hack: fix content width inside hidden tabs */
.tab-content > .tab-pane, .pill-content > .pill-pane {
    display: block;    /* undo display:none          */
    height: 0;         /* height:0 is also invisible */ 
    overflow: hidden;  /* no-overflow                */
}
.tab-content > .active, .pill-content > .active {
    height: auto;      /* let the content decide it  */
} /* bootstrap hack end */

more here: https://groups.google.com/forum/#!topic/twitter-bootstrap-stackoverflow/0Aqzs5s_hEY

51reactions
painreigncommented, Mar 9, 2016

Took ages to figure out:

$('.slick-slider').each(function() {
    $(this).slick("getSlick").refresh();
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Slick slider doesn't work in bootstrap dropdown - Stack Overflow
The problem occurs because the plugin is initialized while being hidden, and that messes with it's size. So here, we're forcing a resize...
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 >
slick-carousel - npm
Start using slick-carousel in your project by running `npm i slick-carousel`. ... Add the slick-theme.css if you want default styling -->.
Read more >
How to Hide and show slide arrows in slick slider?
In this post, we will create a slick slider and later on show you how to show/hide the buttons of the slick slider....
Read more >
https://media.defcon.org/DEF%20CON%2025/DEF%20CON%...
But all of them could hear the hole in the music where Shannon's console should be. ... Chuck came out of the office,...
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