Skip to content

Change width and height to come from getBoundingClientRect rather than offsetWidth/offsetHeight#97

Merged
bvaughn merged 1 commit intomasterfrom
issues/96
Mar 30, 2025
Merged

Change width and height to come from getBoundingClientRect rather than offsetWidth/offsetHeight#97
bvaughn merged 1 commit intomasterfrom
issues/96

Conversation

@bvaughn
Copy link
Copy Markdown
Owner

@bvaughn bvaughn commented Feb 19, 2025

Resolves #96

cc @RoystonS for thoughts

@bvaughn
Copy link
Copy Markdown
Owner Author

bvaughn commented Mar 29, 2025

Hey @RoystonS would still value your thoughts here.

@RoystonS
Copy link
Copy Markdown

Ok, so MDN (https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetWidth) recommends the use of getBoundingClientRect instead of offsetXXX if you don't want the rounding behaviour:

image

So this behaviour sounds excellent. I can see that you're planning to deprecate the other parameters at the next major release. Fabulous stuff.

Out of an abundance of paranoia around a public API I'll raise that it's possible that the change of behaviour of width/height to start returning non-integers might be an issue for some people. (Indeed an app of mine failed in production last week because a third party REST API started returning doubles instead of integers but in that case I had a .NET app typed as 'int' referencing the service's DTO.)

But, because we're entirely within a JS API, using numbers, it shouldn't be an issue?

@bvaughn
Copy link
Copy Markdown
Owner Author

bvaughn commented Mar 30, 2025

Appreciate the thoughtful response. I agree that it seems unlikely to be a problem in this context. I think I'll go for it.

@bvaughn bvaughn merged commit e9c8ef0 into master Mar 30, 2025
@bvaughn bvaughn deleted the issues/96 branch March 30, 2025 15:59
@bvaughn
Copy link
Copy Markdown
Owner Author

bvaughn commented Mar 30, 2025

Just published 1.0.26

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.

scaledHeight + scaledWidth not documented - do they more than just not rounding?

2 participants