Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Masonry block with lazy-loaded images #2031

Open
Kevin-Hamilton opened this issue Dec 29, 2023 · 1 comment
Open

Masonry block with lazy-loaded images #2031

Kevin-Hamilton opened this issue Dec 29, 2023 · 1 comment
Labels
bug This label could be used to identify issues that are caused by a defect in the product.

Comments

@Kevin-Hamilton
Copy link

Description

The Masonry block appears to have issues when images are being lazy loaded. I believe a possible fix is to modify here:

to add a recalculate on image load, like so:

		let m = window.Macy({
			container: targetContainer,
			trueOrder: false,
			waitForImages: false,
			margin,
			columns,
			breakAt: {
				1200: Math.min( columns, 4 ),
				840: Math.min( columns, 3 ),
				740: Math.min( columns, 2 ),
				640: Math.min( columns, 1 )
			}
		});
		m.runOnImageLoad(function () {
			m.recalculate(true);
		}, true);

Step-by-step reproduction instructions

Use a masonry block on a gallery of images which are lazy loaded. The container will get set to an unreasonable height and all the images will be placed at the bottom. Resizing the browser will trigger a recalc and fix the layout. OR, scrolling to the bottom will trigger the remaining images to load and then the container will recalc.

Screenshots, screen recording, code snippet or Help Scout ticket

No response

Environment info

No response

Is the issue you are reporting a regression

No

@Kevin-Hamilton Kevin-Hamilton added the bug This label could be used to identify issues that are caused by a defect in the product. label Dec 29, 2023
@JohnPixle
Copy link
Contributor

@HardeepAsrani I removed this from Triage, feel free to prioritise as you see fit ✌🏻
Thanks @Kevin-Hamilton !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This label could be used to identify issues that are caused by a defect in the product.
Projects
None yet
Development

No branches or pull requests

2 participants