Web/API/IntersectionObserver/root

From Get docs


The IntersectionObserver interface's read-only root property identifies the Element or Document whose bounds are treated as the bounding box of the viewport for the element which is the observer's target. If the root is null, then the bounds of the actual document viewport are used.

Syntax

var root = intersectionObserver.root;

Value

A Element or Document object whose bounding box is used as the bounds of the viewport for the purposes of determining how much of the target element is visible. The intersection of this bounding rectangle, offset by any margins specified in the options passed to the IntersectionObserver() constructor, the target element's bounds, minus the bounds of every element or other object which overlaps the target element, is considered to be the visible area of the target element.

If root is null, then the owning document is used as the root, and the bounds its viewport (that is, the visible area of the document) are used as the root bounds.

Example

This example sets the border of the intersection observer's root element to be a 2-pixel medium green line.

observer.root.style.border = "2px solid #44aa44";

Specifications

Specification Status Comment
Intersection ObserverThe definition of 'IntersectionObserver' in that specification. Working Draft Initial definition

Browser compatibility

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet

root

Experimental'

Chrome

Full support 51

Edge

Full support 15

Firefox Full support 55


Full support 55


No support 53 — 55

Disabled'

Disabled' From version 53 until version 55 (exclusive): this feature is behind the dom.IntersectionObserver.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

IE

No support No

Opera

Full support Yes

Safari

Full support 12.1

WebView Android

Full support 51

Chrome Android

Full support 51

Firefox Android

?

Opera Android

?

Safari iOS

Full support 12.2

Samsung Internet Android

Full support 5.0

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.'
Experimental. Expect behavior to change in the future.
User must explicitly enable this feature.'
User must explicitly enable this feature.


See also