Masonry JS Overlapping Items

后端 未结 7 1419
庸人自扰
庸人自扰 2021-01-30 14:37

I have a very strange problem in here: [Referral Link Removed]. The first row product items overlapped with the items in the second row.

The masonry it

7条回答
  •  伪装坚强ぢ
    2021-01-30 15:09

    I've solved this issue with a settimeout function. By allowing a second or so to pass (depending on the # and file size of the images being downloaded) you can download the images first then apply masonry.

                    $(document).ready(function(){                                                                                                                   
                    setTimeout(function() { masonry_go();masonry_go2();}, 1000);                                                                    
                });     
                $(window).resize(function() 
                {
                    // jQuery
                    $('.grid').masonry( 'destroy')
                    $('.grid2').masonry( 'destroy')                 
                    setTimeout(function() { masonry_go();masonry_go2();}, 1000);                                                                    
                });                 
                function masonry_go(){
                    $('.grid').masonry({
                      // options
                      itemSelector: '.grid-item',
                      columnWidth: 300
                    });                         
                }       
                function masonry_go2(){
                    $('.grid2').masonry({
                      // options
                      itemSelector: '.grid-item2',
                      gutter: 15,
                      columnWidth: 200
                    });                         
                }       
    

提交回复
热议问题