Deleting 1st masonry box (only the 1st) in container breaks layout (reproduced on plugin homepage)
I have a page where I can remove masonry content blocks dynamically through JS. I then recall the masonry function to adjust the layout accordingly, by wrapping this in a function...
$('.container').masonry({
itemSelector: 'block'
});
This works fine for all masonry blocks, other than the first one.
When you delete the first block, all of blocks stack, underneath the new first block, breaking the layout.
This can be reproduced on plugin homepage example, if you open up firebug/devtools and run
$('.masonry-brick').first().remove()
And then resize your browser window
NOTE -- this is most noticeable in Chrome/Safari/IE. In Firefox, it still works arranges correctly, but gives the first block extra space above it (so still incorrect).
I'm also having issues with this. A fix would be great!
Confirmed as an issue for me too. Please fix!
Thanks for submitting this issue! There are two ways to resolve this.
- Set a value for
columnWidth. See http://jsfiddle.net/desandro/DEDW4/ This is the recommended solution. - Or you could trigger
reloadItemsafter the first item is removed. See http://jsfiddle.net/desandro/DEDW4/1/
Please chime in if this doesn't resolve your issue.
Thanks for responding -- the column width option seems to work. So I'll go with that, but in the 2nd jsfiddle you posted, if you click on the first item (exact top left), it does not adjust the layout correctly. And then all subsequent reloads are broken.
Haha, you are a stickler aren't you! Yes, that layout doesn't work as you might expect, but it's doing the best job it can. A columnWidth was not specified, so it defaults to the width of the first item. Hence, I recommend using a columnWidth.
Yup, makes sense, I didn't mean for you to fix it. Column width is definitely fine solution. Was letting you know in case you thought 2nd solution was working etc. Thanks again