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 centerOnInit timing issue #468

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

TheStu
Copy link
Contributor

@TheStu TheStu commented Mar 28, 2024

This addresses this issue: #392

It seems like, maybe depending on what html and CSS you are using in the code surrounding your image, the contentComponent will trigger the ResizeObserver multiple times before the image is actually loaded. Given that the ResizeObserver is coded to only run once, this leaves the image off-center in some cases.

I've set it up so that the ResizeObserver will wait until the contentComponent height or width becomes greater than 0 before triggering the setCenter function. The timeout ensures that the observer will eventually disconnect if a resize never happens. I wasn't sure how long to set that for but 5 seconds seemed reasonable.

@prc5
Copy link
Collaborator

prc5 commented Mar 28, 2024

Let's give it a try 👍

@prc5
Copy link
Collaborator

prc5 commented Mar 28, 2024

Thanks! 🚀

@prc5 prc5 merged commit 8dacc27 into BetterTyped:master Mar 28, 2024
Copy link

🎉 This PR is included in version 3.4.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants