问题
My Isotope layout is returning 0px height on its container. Refreshing the page always resolves the problem.
Has anyone run into this?
Here is my Isotope:
var $container = $('#Stream');
$container.imagesLoaded(function () {
$container.isotope({
itemSelector: '.stream-items',
transformsEnabled: false
});
It occurs consistently albeit intermittently on Chrome, Safari, and FF. By "intermittently" I mean that sometimes it's on the first load, others on the third, or fourth, but eventually always happens.
I'm running on jQuery Mobile and have tried loading it the various options (window.load, pageinit, etc) but it happens regardless.
So, any ideas are much appreciated including any hacks that will force a refresh which always fixes the problem.
Thanks!
UPDATE: Just noticed that resizing the window resets to 0px height too.
回答1:
It looks like Isotope doesn't have enough time to calc the images. So I use window.load instead. Works a treat:
$(window).load(function(){
// Gallery Isotope
$(function(){
var $container = $('#gallery');
$container.isotope({
itemSelector: 'li',
masonry : {
columnWidth : 320
}
});
});
});
来源:https://stackoverflow.com/questions/11942224/isotope-intermittently-returns-0px-height-on-div