IntersectionObserver: thresholds 属性
thresholds 是 接口的一个只读属性,它返回在实例化观察器时使用 IntersectionObserverIntersectionObserver() 所指定的交叉阈值列表。
如果在实例化对象时只提供了一个阈值比例,那么这将是一个包含该单一值的数组。
有关阈值如何工作的更多信息,请参阅 Intersection Observer 页面。
值
一个交叉阈值的数组,最初在实例化观察器时使用 threshold 属性指定。如果只指定了一个观察器,而不是一个数组,那么此值是一个包含该阈值的一个条目数组。无论您原始 threshold 数组的顺序如何,此数组始终按数值递增的顺序排序。
如果在实例化观察器时使用 IntersectionObserver() 没有包含 threshold 选项,则 thresholds 的值为 [0]。
注意: 尽管您可以在 IntersectionObserver() 构造函数中指定的 options 对象有一个名为 threshold 的字段,但此属性名为 thresholds。如果您错误地在 options 中使用了 thresholds 作为字段名,那么 thresholds 数组最终将是 [0.0],这很可能不是您期望的结果。
规范
| 规范 |
|---|
| 交集观察器 # dom-intersectionobserver-thresholds |
浏览器兼容性
加载中…