ampproject / ampproject/amphtml

Remove measuring APIs from the runtime

Open
#31,540 4 comments 0 reactions 2 assignees Claimed by @samouri View on GitHub
Type: Feature Request
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

Proposed plan:

1. Only supply one measurement per load/layout operation.
2. Provide this measurement in the appropriate callbacks to avoid misuse. E.g. `layoutCallback(size)`.
3. The elements that need to react to size changes should take care of it themselves via `ResizeObserver`.
4. `getLayoutBox` and related APIs should be phased out. Many uses are currently incorrect or imprecise. We could instead add one `getSize`-style API, but we should call it clearly to explain that this is the size at the last load/layout operation and has no guarantees on freshness.

TODO:

- [x] Create resize-observer utilities.
- [ ] Supply layout size to the `layoutCallback` as a transaction argument value.
- [x] Phase out `BaseElement.onMeasureChanged` (the clearest indication of resize tracking functionality).
- [x] Phase out `getPageLayoutBox` API.
- [ ] Phase out `getLayoutBox` API.
- [ ] Phase out `getIntersectionChangeEntry` API.
- [ ] Phase out `getIntersectionElementLayoutBox` API.
- [ ] Phase out `getLayoutWidth` API.
- [x] Reimplement ini-load via intersection observer
- [ ] Reimplement resizer via intersection observer

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.