← Back to release summary

IntersectionObserver Document Root

Category
JavaScript
Type
New or changed feature
Status
Enabled by default (Chrome 81)
Intent stage
Prepare to ship

WPT details: https://github.com/web-platform-tests/wpt/pull/21222

Summary

Allow the IntersectionObserver constructor to take a Document as the 'root' argument, causing intersections to be calculated against the scrolling viewport of the document.

Motivation

This is primarily targeted towards observers running in an iframe; prior to this feature, there was no way to measure intersection with the scrolling viewport of the iframe's document.

Standards & signals

Ecosystem

Docs: https://w3c.github.io/IntersectionObserver/#calculate-intersection-rect-algo

Explainers: https://github.com/w3c/IntersectionObserver/issues/372

View on chromestatus.com