-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Low-hanging fruit replacements for getLayoutWidth/Box uses and deprecate some measurement APIs #31490
Conversation
@@ -321,7 +321,7 @@ export class AmpScrollableCarousel extends BaseCarousel { | |||
* @private | |||
*/ | |||
withinWindow_(pos, callback) { | |||
const containerWidth = this.element.getLayoutWidth(); |
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.
Are we guaranteed that these sync measures won't cause reflows/jank? Shouldn't we still be relying on vysnc?
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.
Not in this case, because:
- There's more measuring code is peppered there, which negates any benefits.
- It's a component in the deprecation track.
@@ -114,7 +114,7 @@ export class AmpVizVega extends AMP.BaseElement { | |||
|
|||
/** @override */ | |||
onLayoutMeasure() { | |||
const box = this.getLayoutBox(); | |||
const box = this./*OK*/ getBoundingClientRect(); |
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 question here re. sync measurement
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.
Measurements in the onLayoutMeasure
are technically free since they are called in a version of vsync.measure from resources-impl. But it's also a deprecated component.
…ate some measurement APIs (ampproject#31490) * Low-hanging fruit replace getLayoutWidth/Box uses and deprecated measurement APIs * test fixes
Mostly replaced
getLayoutBox/getLayoutWidth
with a direct measurement where the old code is doing additional measurements anyway.Partial for #31540.