-
Notifications
You must be signed in to change notification settings - Fork 352
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
Refactor offsetHeight use float-compat API #948
Conversation
aceb59c
to
5639ca1
Compare
79aa4f2
to
77d3950
Compare
@@ -29,18 +40,52 @@ const Header = PageObject.extend({ | |||
|
|||
/** | |||
* Retrieves selected header cell width. | |||
* | |||
* Deprecated: offsetWidth returns a rounded integer, and so can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use @deprecated
jsdoc tag
*/ | ||
get width() { | ||
return findElement(this).offsetWidth; | ||
}, | ||
|
||
/** | ||
* Retrieves selected header cell height. | ||
* | ||
* Deprecated: offsetHeight returns a rounded integer, and so can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: same
/** | ||
* Resizes this column by dragging right border several pixels. | ||
/* | ||
* This API is deprecated, prefer the more explicit resizeLogicalSize. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
77d3950
to
f3eb2b4
Compare
f3eb2b4
to
dfec26c
Compare
56abd37
to
675d8fb
Compare
f6e3a12
to
5e417a5
Compare
5e417a5
to
6ebd499
Compare
offsetHeight returns an integer, making it a poor API to base the determination of element scale on. Instead, use an alternative and precise API. Only allow a reasonable amount of precision by decimal place, and for cases where the scale number is reasonably rounded do so. The offsetHeight method includes padding in returned sizes, where getComputedStyle does not. Check them against each other, and if they diverge signifcantly (>1) throw an exception. To make ember-table itself compatible with this appraoch, pass the `scale` value around the system a bit more instead of trying to derive it in many places.
6ebd499
to
3aed24a
Compare
I've confirmed in an internal codebase that this improves how well a table can match the intended container it is in. Landing it, and I'll but a beta/preview release for Ember Table v6 sometime soon. |
Released in v6.0.0-0 prerelease |
offsetHeight
, per MDN, is an API which returns integer values. This makes is inappropriate to use in calculations of current UI scale (usually from a transform) as it rounds any floating point height into an integer.This PR changes the
getScale
function to usegetComputedStyle
to read off the logical height of the element. This API supports greater precision (to at least 3 digits) though it also may not provide the same level of precision asgetBoundingClientRect
.This prevents the positioning data for cells (which is impacted by
scale
) from being corrupted by heights which are at decimal precision.