IntersectionObserver:takeRecords() 方法

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2019.

IntersectionObservertakeRecords() 方法返回一个 IntersectionObserverEntry 对象数组,每个对象包含目标元素自上次相交检查以来所经历的相交状态变化——可以显式地通过调用此方法或隐式地通过观察器的回调获得。

备注: 如果使用回调来监视这些更改,则无需调用此方法。调用此方法会清除挂起的相交状态列表,因此不会运行回调。

语法

js
takeRecords()

参数

无。

返回值

IntersectionObserverEntry 对象数组,每个对象包含目标元素自上次相交检查以来与根的相交状态变化。

规范

Specification
Intersection Observer
# dom-intersectionobserver-takerecords

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
takeRecords

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

参见