-
- Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Description
Describe the problem
Svelte doesn't allow binding to naturalWidth and naturalHeight of img tags. Those are read only properties that reflect the natural width of an image (it's native resolution).
Describe the proposed solution
I'd like to be able to bind to those properties, so I can get those values simply out of images.
<script> let naturalWidth = 0; </script> <img src="something.jpg" bind:naturalWidth> The images natural width is {naturalWidth}
Alternatives considered
Without binding, I can react to onload and get the naturalWidth/naturalHeight there. Using binds seems more like "the svelte way".
<script> let naturalWidth = 0; function imageLoaded(e) { naturalWidth = e.target.naturalWidth } </script> <img src="something.jpg" on:load={imageLoaded}> The imaages natural width is {naturalWidth}
Importance
nice to have
Metadata
Metadata
Assignees
Labels
No labels