kombai / freewall

Freewall is a cross-browser and responsive jQuery plugin to help you create grid, image and masonry layouts for desktop, mobile, and tablet...
MIT License
1.85k stars 375 forks source link

Content flashes briefly on loading #139

Open drawcard opened 9 years ago

drawcard commented 9 years ago

Hi, when I load my webpage using Freewall, the "cells" / "bricks" of content flash up on my screen briefly before they assemble themselves on screen. I notice this sometimes happens on the Freewall website as well. Is there anything I can use to hide all of the blocks before they are ready for display?

Here's a link to a GIF showing what's going on. You can see the items loading up in a single line, then they disappear before reappearing again (using the method you've outlined in the CSS3 Transitions example).

Demo

kombai commented 9 years ago

Yes, This is the code:

var imgs = wall.container.find("img");
var length = imgs.length;
imgs.css({visibiliy: "hidden"}).error(function() {
 length --;
  if (!length) {
   wall.fitWidth();
  imgs.css({visibility: "visible"})
 }
}).load(function() {
 length --;
 if (!length) {
   wall.fitWidth();
  imgs.css({visibility: "visible"})
 }
})