miromannino / Justified-Gallery

Javascript library to help creating high quality justified galleries of images. Used by thousands of websites as well as the photography community 500px.
http://miromannino.github.io/Justified-Gallery/
MIT License
1.7k stars 299 forks source link

First page refresh causes wrong image positions #150

Open bartosz-malec opened 8 years ago

bartosz-malec commented 8 years ago

I have a problem with grid on first page load. After first page load or hard refresh (ctrl + F5), grid looks bad, and images has incorrectly calculated widths (width of images is 100%). After normal page refresh everything back to narmal and images has good positions and sizes.

Have you ever met this problem?

bartosz-malec commented 8 years ago

First photo with width 100% test1 Second photo after refresh the page test2

miromannino commented 8 years ago

Yes it happened one time... can you send me a link to this page? Or with the mail the html with the images (saving the page with the browser)? Thank you

bartosz-malec commented 8 years ago

I sent an email to you with access credentials.

bartosz-malec commented 8 years ago

I resolved this problem. I run justifiedGalleryCode in $("document").ready(function() { $("document").load(function() { [justifiedGalleryCode] }); });

Sebastiansc commented 7 years ago

@bartosz-malec what is that justifiedGalleryCode?

voletiv commented 7 years ago

@bartosz-malec I'm facing a similar issue where the widths are 100% in all cases, could you please tell us what your JustifiedGalleryCode is?

danygit commented 7 years ago
var isDomReady = false;
var isWinLoad = false;

$(document).ready(function() {
    isDomReady = true;
    initJustifiedGallery();
});

$(window).load(function() {
    isWinLoad = true;
    initJustifiedGallery();
});

function initJustifiedGallery()
{
if (isWinLoad === true && isDomReady === true) {
   $('.gallery').justifiedGallery({
                rowHeight: 180,
                lastRow: 'nojustify',
                margins: 6,
                selector: 'div'
            });
}
}

And no more double refresh. it's work