masonry icon indicating copy to clipboard operation
masonry copied to clipboard

Deleting 1st masonry box (only the 1st) in container breaks layout (reproduced on plugin homepage)

Open ndreckshage opened this issue 13 years ago • 7 comments

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

ndreckshage avatar Feb 11 '13 22:02 ndreckshage

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).

ndreckshage avatar Feb 11 '13 22:02 ndreckshage

I'm also having issues with this. A fix would be great!

rchampion avatar Feb 11 '13 23:02 rchampion

Confirmed as an issue for me too. Please fix!

katherinessmith avatar Feb 12 '13 00:02 katherinessmith

Thanks for submitting this issue! There are two ways to resolve this.

  1. Set a value for columnWidth. See http://jsfiddle.net/desandro/DEDW4/ This is the recommended solution.
  2. Or you could trigger reloadItems after the first item is removed. See http://jsfiddle.net/desandro/DEDW4/1/

Please chime in if this doesn't resolve your issue.

desandro avatar Feb 12 '13 03:02 desandro

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.

ndreckshage avatar Feb 12 '13 03:02 ndreckshage

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.

desandro avatar Feb 12 '13 03:02 desandro

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

ndreckshage avatar Feb 12 '13 03:02 ndreckshage