当站点加载时,砌体箱首先排列在左侧(http://herrfischerhamburg.de/re/),1 或 2 秒后,它们以正确的排水沟宽度排列。知道如何在页面加载时直接以正确的装订线宽度排列它们吗?
function init_masonry(){
var $container = $('.content');
var gutter = 12;
var min_width = 250;
$container.imagesLoaded( function(){
$container.masonry({
itemSelector : '.box',
gutterWidth: gutter,
isAnimated: true,
columnWidth: function( containerWidth ) {
var num_of_boxes = (containerWidth/min_width | 0);
var box_width = (((containerWidth - (num_of_boxes-1)*gutter)/num_of_boxes) | 0) ;
if (containerWidth < min_width) {
box_width = containerWidth;
}
$('.box').width(box_width);
return box_width;
}
});
});
}