IntersectionObserver: thresholds 屬性
thresholds 是 介面的一個只讀屬性,它返回在例項化觀察器時使用 IntersectionObserverIntersectionObserver() 所指定的交叉閾值列表。
如果在例項化物件時只提供了一個閾值比例,那麼這將是一個包含該單一值的陣列。
有關閾值如何工作的更多資訊,請參閱 Intersection Observer 頁面。
值
一個交叉閾值的陣列,最初在例項化觀察器時使用 threshold 屬性指定。如果只指定了一個觀察器,而不是一個數組,那麼此值是一個包含該閾值的一個條目陣列。無論您原始 threshold 陣列的順序如何,此陣列始終按數值遞增的順序排序。
如果在例項化觀察器時使用 IntersectionObserver() 沒有包含 threshold 選項,則 thresholds 的值為 [0]。
注意: 儘管您可以在 IntersectionObserver() 建構函式中指定的 options 物件有一個名為 threshold 的欄位,但此屬性名為 thresholds。如果您錯誤地在 options 中使用了 thresholds 作為欄位名,那麼 thresholds 陣列最終將是 [0.0],這很可能不是您期望的結果。
規範
| 規範 |
|---|
| 交集觀察器 # dom-intersectionobserver-thresholds |
瀏覽器相容性
載入中…