ampproject / ampproject/amphtml
Remove measuring APIs from the runtime
- 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
Assessment
This issue has not been assessed yet.