hongkhanh / gridify

A lightweight script for creating a Pinterest-like grid using JQuery, pure javascript or YUI with image loaded
http://hongkhanh.github.io/gridify
MIT License
124 stars 33 forks source link

gridify only lays out after the page changes size #4

Closed developius closed 9 years ago

developius commented 9 years ago

Having this issue - the imgs only get layed out after I either zoom in or zoom out on the page. This doesn't happen on any of the example pages. This is my code:

    $(document).ready(function(){
        var albumId = "xxxxxxxxxxxxx";
        $.ajax({
            dataType:"json",
            url:'http://graph.facebook.com/' + albumId + '?fields=photos.fields%28images,source,picture,link,name%29,photos.limit%2840%29&_=1425840156371',
            success:function(incomming){
                var photos = incomming.photos.data;
                for (var key in photos){
                    $("#photos").append("<img src='" + photos[key].source + "' class='image'>");
                }
            },
            error:function(err){
                console.log("Error collecting photos: " + JSON.stringify(err, null, 2));
            }
        });
    });
    $(window).load(function() {
        var options = {
            items:3,
            srcNode: 'img',
            margin: '20px',
            width: '250px',
            resizable: true,
            transition: 'all 0.5s ease'
        }
        $('.grid').gridify(options);
    });

My .grid element starts out as an empty div.

developius commented 9 years ago

Appears to be a timing issue.