JavaScript How to discover and fill empty spaces between elements in isotope jquery grid?

When resizing an element in isotope using perfectMasonry extention because of the variable sizes of the elements it creates some spaces. I want to check with jquery every time there is a relayout if an empty space is created. If it's created I want to insert a new element with size of the gap that is created between other elements to fill the space.

I tried using a background on a parent div of the container and with some css shadow-box to make it look nice but didnt make it. The code I am working on http://jsfiddle.net/TqVSs/ (could not link to perfectMasonry source from github so superMasonry is on the javascript box.Scroll down to find my code)

$('#container').isotope({
layoutMode: "perfectMasonry",
perfectMasonry: {
        columnWidth: 0,
        rowHeight: 125
}
})            



 $('#container').delegate( '.element', 'click', function(){
        if($(this).hasClass("dummy")==false){
            $(this).toggleClass('large');   
            $('#container').isotope('reLayout');
        }
    });
Answer:1

Use Packery!

Packery layouts are designed to fill gaps. Packery also has great support for variable sizes.

Answer:2

Assume that I have two literals: false and 1. If I invoke function toString() on both of them, I get: false.toString() // false 1.toString() // Uncaught SyntaxError: Unexpected token ILLEGAL ...

Assume that I have two literals: false and 1. If I invoke function toString() on both of them, I get: false.toString() // false 1.toString() // Uncaught SyntaxError: Unexpected token ILLEGAL ...

Consider the following code that contains a simplified implementation of Bluebird's Promise.settle: var a = Promise.reject('a'); var b = Promise.resolve('b'); var c = Promise.resolve('c'); var ...

Consider the following code that contains a simplified implementation of Bluebird's Promise.settle: var a = Promise.reject('a'); var b = Promise.resolve('b'); var c = Promise.resolve('c'); var ...

Is it possible to use CSS to highlight the section that has been linked to? If not can I get the #link in JavaScript some how? IE var section = $(window).link(); Thanks for your time

Is it possible to use CSS to highlight the section that has been linked to? If not can I get the #link in JavaScript some how? IE var section = $(window).link(); Thanks for your time

I am currently switching the menu of my site from pure JavaScript to jQuery. My menu has a rollout / rollin effect. The menu has an outer wrapper which has an onmouseout event set. If this fires, the ...

I am currently switching the menu of my site from pure JavaScript to jQuery. My menu has a rollout / rollin effect. The menu has an outer wrapper which has an onmouseout event set. If this fires, the ...