-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Leaflet .getSize() issue with Svelte #5988
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
Comments
I'm not sure how this is an issue with Svelte. It seems that you're trying to get the size of a layer before it has properly rendered. It's a race condition. |
@antony thank you for the response. This works fine when not using Svelte - see https://github.com/gavinr/leaflet-custom-layer-issue/blob/master/public/standalone.html (sorry, should have included this in the original issue report), which is what makes me think it's an issue with Svelte. |
It seems like the DOM or the styles sometimes have not fully loaded when this function gets called. Note I am using svelte actions here to call the function. When I use an action like this can I assume the DOM and styles are loaded? If not, what's a better way to guarantee that the the DOM and styles are loaded? |
You should be able to assume that the DOM and any styles are loaded, yes, but that's not to say that instantiating the |
Describe the bug
When creating a leaflet map, the leaflet
getSize()
function sometimes returns the wrong size within a Svelte app.To Reproduce
in a CHROMIUM-based browser (example: google chrome), open http://localhost:5000/ and refresh/hard-refresh a bunch of times until you see the "y" value in the developer console be an unreasonably small (~30 or 40) size.
Expected behavior
The text was updated successfully, but these errors were encountered: