IntersectionObserverEntry - 描述了在特定转换时刻目标元素与其根容器之间的交集
这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。
IntersectionObserverEntry 是 Intersection Observer API 的接口,描述了在特定转换时刻目标元素与其根容器之间的交集。可以通过 IntersectionObserver 回调的 entries 参数获得 IntersectionObserverEntry 实例;否则,只能通过调用 IntersectionObserver.takeRecords() 来获取这些对象。
属性
IntersectionObserverEntry.boundingClientRect 只读
以 DOMRectReadOnly 的形式返回目标元素的 bounds 矩形。边界的计算方法如 Element.getBoundingClientRect() 的文档中所述。
IntersectionObserverEntry.intersectionRatio 只读
返回 intersectionRect 与 boundingClientRect 的比率。
IntersectionObserverEntry.intersectionRect 只读
返回一个 DOMRectReadOnly 表示目标可见区域的。
IntersectionObserverEntry.isIntersecting 只读
一个布尔值,如果目标元素与交集观察者的根相交,则为 true。如果值为 true,则 IntersectionObserverEntry 描述了到交叉状态的转换;如果值为 false,那么过渡是从交叉到不相交。
IntersectionObserverEntry.rootBounds 只读
返回一个 DOMRectReadOnly,表示交集观察者的根。
IntersectionObserverEntry.target 只读
返回一个 Element,表示与根的交集发生了变化的元素。
IntersectionObserverEntry.time 只读
一个 DOMHighResTimeStamp 表示相对于 IntersectionObserver 的时间原点记录交叉点的时间。
方法
该接口没有方法。
规范
| 规范 | 状态 | 备注 |
|---|---|---|
| Intersection Observer IntersectionObserverEntry 的定义 |
工作草案 | Initial definition |
桌面浏览器兼容性
| 特性 | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| 基础支持 | 51 | 15 | 55 53 — 55 | 不支持 | 未知 | 未知 |
boundingClientRect | 51 | 15 | 55 53 — 55 | 不支持 | 未知 | 未知 |
intersectionRatio | 51 | 15 | 55 53 — 55 | 不支持 | 未知 | 未知 |
intersectionRect | 51 | 15 | 55 53 — 55 | 不支持 | 未知 | 未知 |
isIntersecting | 51 | 16 | 55 53 — 55 | 不支持 | 未知 | 未知 |
rootBounds | 51 | 15 | 55 53 — 55 | 不支持 | 未知 | 未知 |
target | 51 | 15 | 55 53 — 55 | 不支持 | 未知 | 未知 |
time | 51 | 15 | 55 53 — 55 | 不支持 | 未知 | 未知 |
移动浏览器兼容性
| 特性 | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
|---|---|---|---|---|---|---|---|
| 基础支持 | 51 | 51 | 支持 | 未知 | 未知 | 未知 | 未知 |
boundingClientRect | 51 | 51 | 支持 | 未知 | 未知 | 未知 | 未知 |
intersectionRatio | 51 | 51 | 支持 | 未知 | 未知 | 未知 | 未知 |
intersectionRect | 51 | 51 | 支持 | 未知 | 未知 | 未知 | 未知 |
isIntersecting | 51 | 51 | 不支持 | 未知 | 未知 | 未知 | 未知 |
rootBounds | 51 | 51 | 支持 | 未知 | 未知 | 未知 | 未知 |
target | 51 | 51 | 支持 | 未知 | 未知 | 未知 | 未知 |
time | 51 | 51 | 支持 | 未知 | 未知 | 未知 | 未知 |