I think the issue is that postSlide()鈥攁 callback invoked from animateSlide() which in turn calls animateHeight()鈥攔uns 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;
}
Can you please create a jsfiddle expressing the faulty behavior?
Here it is:
https://jsfiddle.net/zf1jvah2/6/
If you remove animateHeight()
https://jsfiddle.net/zf1jvah2/5/
The issue doesn't appear (or, on jsfiddle, sometimes it appears on load but not when changing slides).
(The embeded code is the lastest version, plus the fix I suggested here)
UPDATED!
We're hit by this as well in the scenario where images are slow to load.
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');
});
}
GordonDrop's fix also worked for me when I was hiding the slider, changing a slide with arrow keys, then showing it again where it had the same 1px height issue.
@GordonDrop thank you. triggering window's resize event did the trick for me on react-slick.
window.dispatchEvent(new Event('resize'));
call this on image load
@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();
});
Most helpful comment
@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(); });