Masonry Plugin: Resizing div wont cause reshuffle

最后都变了- 提交于 2019-12-04 06:07:39

I believe you need to run the masonry function agian when your re-size button is clicked.

$("a.button").toggle(function(){
    $(this).addClass("flip");
    $("div#container").fadeOut("fast", function() {
    $(this).fadeIn("fast").addClass("resize");
    // run masonry again
    $('#container').masonry({      
      itemSelector : '.item',
      columnWidth : 240
    });
});
frozenkoi

From http://masonry.desandro.com/methods.html#reloaditems , calling .masonry('reloadItems') will grab (possibly new) items that match itemSelector and reposition the bricks, but calling .masonry() will just reposition items based on the most recent dimensions of its items.

Try triggering the resize event with jquery:

$(window).trigger('resize');

It worked for me!

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