IntersectionObserver.root - Web APIs 编辑

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

SpecificationStatusComment
Intersection Observer
The definition of 'IntersectionObserver' in that specification.
Working DraftInitial definition

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:130 次

字数:3505

最后编辑:6年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文