Owlcarousel2: Chrome and autoHeight shows 1px height image when refresh page

Created on 3 Oct 2014  路  10Comments  路  Source: OwlCarousel2/OwlCarousel2

Hi,

When I'm using chrome and refresh the page, the image is only 1px height.

You can check the bug here. Only when refresh the page and chrome:

http://cultura.burjassot.org/teatro/la-asombrosa-historia-de-mr-snow/

Most helpful comment

You need to use $(window).load instead of $(document).ready if you want to use autoHeight with images. ready fires before images are loaded, so autoHeight is working as it should by setting the height to be 0 or 1 pixels tall. Another option would be to set up the carousel on ready, but trigger a refresh.owl.carousel on load so that the carousel knows to re-check the element's height.

All 10 comments

it's working now, close the issue

The bug is still.
Now it is working but with a css trick:

$(document).ready(function() {
$('#galeria').css({'opacity':'0'});
});

$(window).load(function() {
$('#galeria').owlCarousel({
autoHeight: true,
items : 1,
});
$('#galeria').css({'opacity':'1'});
});

Can someone verify that this is still an issue?

Please upgrade to the newest version of Owl Carousel, released today, and re-open this issue if it persists.

I can still replicate this issue when calling from document.ready, if the call is made with window.load everything works.

http://codepen.io/anon/pen/oXRMKQ

You need to use $(window).load instead of $(document).ready if you want to use autoHeight with images. ready fires before images are loaded, so autoHeight is working as it should by setting the height to be 0 or 1 pixels tall. Another option would be to set up the carousel on ready, but trigger a refresh.owl.carousel on load so that the carousel knows to re-check the element's height.

This thread seems a little divided. Can anyone confirm that using $(window).load is the proper/best way to initiate the the owl slider with images and autoHeight? The autoHeight demo uses <div>s with set heights in CSS and not responsive heights from images like many developers are intending to do. It makes sense that the demo is able to use $(document).ready without issue. Using $(window).load with images works for me but there is a FOUC.

$(window).load works for me too

confirm - $(window).load - works for me as well
Thanks!

I just had this error and can also confirm window.onload works.
Thanks for the tip.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hemanthsp picture hemanthsp  路  3Comments

Uranbold picture Uranbold  路  3Comments

leighfarrell picture leighfarrell  路  3Comments

SoufianeAbid picture SoufianeAbid  路  3Comments

jhig85 picture jhig85  路  3Comments