Masonry Overlapping (Imbalance2 Bug)

僤鯓⒐⒋嵵緔 提交于 2019-12-25 04:44:02

问题


I built my site with Wordpress.org and the theme calls Imbalance2. I noticed that this theme has a bug and I searched topics about the overlapping issue because of Masonry js. I use the imagesLoaded (from user Leger at Using masonry with imagesloaded, thanks!): it works but sometimes my Chrome stills overlapping. I decide to add a pagination instead the "Lazy Load" (to avoid more problems…) but I can't merge imagesLoaded for #boxes and #related…

Could you please help me? Here my site address

Thanks so much for your time!!!

<script src="http://imagesloaded.desandro.com/imagesloaded.pkgd.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {

// grid
var $boxes = $('.box');
$boxes.hide();

var $container = $('#boxes');
$container.imagesLoaded( function() {
$boxes.fadeIn();

$container.masonry({
itemSelector: '.box',
columnWidth: 290,
gutterWidth: 40
});
});

$('#related').masonry({
    itemSelector: '.box',
    columnWidth: 290,
    gutterWidth: 40
}).masonry('reload');

});
</script>

回答1:


This tweak is a fix on chrome and safari browser.

Add this line.

jQuery("img").load(function() { jQuery(".container_class").masonry(); //this tweak is a fix on chrome and safari browser });




回答2:


Here the solution I found. As I said I changed the "Lazy Load" for pagination and I wrote the code below thanks to some users that shared their solutions in this Forum.

<script src="http://imagesloaded.desandro.com/imagesloaded.pkgd.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {

// grid
var $boxes = $('.box');
$boxes.hide();

var $container = $('#boxes');
$container.imagesLoaded( function() {
$boxes.fadeIn();

$('#boxes').masonry({
    itemSelector: '.box',
    columnWidth: 286,
    gutterWidth: 40
});
});

var $container = $('#related');
$container.imagesLoaded( function() {
$('#related').masonry({
    itemSelector: '.box',
    columnWidth: 286,
    gutterWidth: 40
});
});

});
</script>


来源:https://stackoverflow.com/questions/25734215/masonry-overlapping-imbalance2-bug

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