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.

adaptiveHeight animation makes lazy loaded slides 1px tall

See original GitHub issue

I think the issue is that postSlide()—a callback invoked from animateSlide() which in turn calls animateHeight()—runs after animateHeight(); but animateHeight() should run after postSlide() because it is from postSlide() that setPosition() gets called after lazy loading a new image (and it is here that the $list’s height is set).

Notes: It doesn’t seem to happen on all browsers (confirmed on desktop Google Chrome 46.0.2490.86), and where it does, it’s not every time.

The fix below (found here) doesn’t work reliably: .slick-slide { height: auto; }

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

3reactions
proteocommented, Jun 17, 2019

@GordonDrop thanks, this put me on the right track. For newcomers, this code fixes the issue for me with 1.9.0 version (which uses events):

$('.some-element').slick({
  lazyLoad: 'ondemand',
  adaptiveHeight: true,
  slidesToShow: 1,
  slidesToScroll: 1
})
.on('lazyLoaded', function(event, slick, image, imageSource) {
  slick.resize();
});
3reactions
GordonDropcommented, Feb 27, 2017

I’ve encountered same issue. It took me a while to deal with it. My workaround:

init: function (e, slick) {
    slick.$slider.find('img').first().on('load', function () {
      $(window).trigger('resize');
    });
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Change height of Slick Carousel - css - Stack Overflow
I was having to set the height eg .slick-carousel{width: 200px;} because adaptive height wasnt working and slick was making the carousel as ...
Read more >
Preventing Content Reflow From Lazy-Loaded Images
When a user scrolls and images are lazy-loaded, those img elements go from a height of 0 pixels to whatever they need to...
Read more >
ThemeNectar | Changelogs - Salient
Fixed Salient Studio template library lazy loading to correctly work on all servers. Updated Salient Nectar Slider to v1.7.2.
Read more >
Lazy Loading Images using Slick Slider - Solodev
Step 3 - Add the CSS below to a file called lazy-slide.css ; 1. /* Slider */ ; 2 .slick-slider { ; 3....
Read more >
Slick Slider Accessibility Demo - CodePen
... height: 100%;\\n min-height: 1px;\\n}\\n[dir='rtl'] .slick-slide\\n{\\n float: ... slider.trigger('lazyLoaded', [_, image, imageSource]);\\n });\\n\\n } ...
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