Isotope intermittently returns 0px height on div

有些话、适合烂在心里 提交于 2019-12-11 08:05:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!