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

Fix layout jumps for images #6474

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix layout jumps for images #6474

wants to merge 1 commit into from

Conversation

gaearon
Copy link
Contributor

@gaearon gaearon commented Nov 17, 2024

I've noticed the aspectRatio value here fluctuates between user-submitted measurement vs measurement on fetch. The fluctuation is small but this leads to an extra setState and potentially to tiny layout jumps. And if the aspect ratio was not specified at all, the layout jump can be significant — per each such image.

Screenshot 2024-11-17 at 22 58 01

We should never layout jump in feed. So let's either use the provided aspect, or assume it's a square.

Also lets us avoid a setState.

Test Plan

Verify images show up appropriately sized, as before (try tall, wide, square images).

Comment out the = image.aspectRatio part and verify that missing measurements are handled gracefully.

Verify lightbox works in all cases.

Copy link

Old size New size Diff
8.05 MB 8.05 MB -54 B (-0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants