desandro / masonry

:love_hotel: Cascading grid layout plugin
https://masonry.desandro.com
16.38k stars 2.11k forks source link

Masonry does not set height correctly with 4 items (3 columns) and 4th item is right aligned instead of left #1048

Closed therealgilles closed 6 years ago

therealgilles commented 6 years ago

I have a grid with 3 columns. The first three elements are displayed by default and there is a load more button to display more. When I click on the 'load more' button, it destroys the old masonry grid and recreates a new one.

The issue is then that the height is not set correctly for 4 elements (the height is set for 3). Additionally the 4th element is right aligned instead of left aligned.

I will try to create a testcase soon. In the meantime, I am looking at any hint as to why this would be happening.

therealgilles commented 6 years ago

Nevermind, it appears the issue is with the Essential Elementor post grid plugin calling destroy and not waiting before calling masonry again. Wish they would use the append method instead. Using destroy and calling masonry again creates an unnecessary jerking on screen as all elements get reset and replaced.

therealgilles commented 6 years ago

Hmm so the issue seems to be that my elements do not have a hardcoded height specified. Is that a requirement? It is not specified anywhere I can find.

desandro commented 6 years ago

I'm sorry to see you're having trouble with Masonry. Could you provide a reduced test case? See Submitting Issues in the contributing guidelines.