metafizzy / packery

:bento: Gapless, draggable grid layouts
https://packery.metafizzy.co
4.13k stars 315 forks source link

Grid flickers on load for dynamic elements #528

Closed ooozydev closed 5 years ago

ooozydev commented 5 years ago

When clicking and rendering elements, the grid loads successfully, but flickers and re-layout all of the elements again. How can I fix this?

ezgif-1-2f073115dfac

Test case: http://dev.oozy.me/el/

$(function() {

$(function() {
  var filemanager = $(".filemanager"),
    breadcrumbs = $(".breadcrumbs"),
    fileList = filemanager.find(".file-list"),
    folderList = filemanager.find(".folder-list");

  var $grid = fileList.packery({
      itemSelector: "li",
      gutter: 0
    });

....

function render() {
      ...
           // append elems to dom
      ...
      $grid.imagesLoaded().progress(function() {
        $grid.packery('reloadItems').packery('layout');
      });

}

});
ooozydev commented 5 years ago

Fixed, had to add transitionDuration: 0 option.