IntersectionObserverEntry 🧪
此 API 目前仅在 React Native 的 Canary 和 Experimental 渠道中可用。
如果你想尝试它,请在你的应用中 启用 Canary 渠道。
IntersectionObserverEntry 接口,如 Web 规范中所定义。它描述了在某个特定过渡时刻,目标元素与其根容器之间的交集情况。
IntersectionObserverEntry 的实例会作为 entries 参数传递给 IntersectionObserver 回调。
参考
实例属性
boundingClientRect
参见 MDN 中的文档。
返回目标元素的边界矩形,类型为 DOMRectReadOnly。
intersectionRatio
参见 MDN 中的文档。
返回 intersectionRect 与 boundingClientRect 的比率。
intersectionRect
参见 MDN 中的文档。
返回表示目标可见区域的 DOMRectReadOnly。
isIntersecting
参见 MDN 中的文档。
一个布尔值,如果目标元素与交叉观察器的根相交,则为 true。如果为 true,则 IntersectionObserverEntry 描述的是进入相交状态的过渡;如果为 false,则表示过渡是从相交到不相交。
rnRootIntersectionRatio ⚠️
这是 React Native 特有的扩展。
返回 intersectionRect 与 rootBounds 的比率。
get rnRootIntersectionRatio(): number;
这与 intersectionRatio 类似,但它是相对于根的边界框而不是目标的边界框计算得出的。这对应于 rnRootThreshold 选项,并允许你确定目标元素覆盖了根区域的百分比。
rootBounds
参见 MDN 中的文档。
返回交叉观察器根的 DOMRectReadOnly。
target
参见 MDN 中的文档。
其与根的交叉状态发生变化的 Element。
time
参见 MDN 中的文档。
一个 DOMHighResTimeStamp,表示记录该交叉状态的时间,相对于 IntersectionObserver 的时间原点。