1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
---
title: IntersectionObserver.thresholds
slug: Web/API/IntersectionObserver/thresholds
translation_of: Web/API/IntersectionObserver/thresholds
---
<div>{{APIRef("Intersection Observer API")}}{{draft}}{{SeeCompatTable}}</div>
<p>The {{domxref("IntersectionObserver")}} interface's read-only <strong><code>thresholds</code></strong> property returns the list of intersection thresholds that was specified when the observer was instantiated with {{domxref("IntersectionObserver.IntersectionObserver", "IntersectionObserver()")}}. If only one threshold ratio was provided when instanitating the object, this will be an array containing that single value.</p>
<p>See {{SectionOnPage("/en-US/docs/Web/API/Intersection_Observer_API", "Thresholds")}} to learn how thresholds work.</p>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox"><var><code>var <em>thresholds</em> = </code>IntersectionObserver</var>.thresholds;
</pre>
<h3 id="Value">Value</h3>
<p>An array of intersection thresholds, originally specified using the <code>threshold</code> property when instantiating the observer. If only one observer was specified, without being in an array, this value is a one-entry array containing that threshold. Regardless of the order your original <code>threshold</code> array was in, this one is always sorted in numerically increasing order.</p>
<p>If no <code>threshold</code> option was included when <code>IntersectionObserver()</code> was used to instantiate the observer, the value of <code>thresholds</code> is simply <code>[0]</code>.</p>
<div class="note">
<p>Be careful! Although the <code>options</code> object you can specify when creating an {{domxref("IntersectionObserver")}} has a field named {{domxref("IntersectionObserver.threshold", "threshold")}}, this property is called <code>thresholds</code>. Confusing? Yes. If you accidentally use <code>thresholds</code> as the name of the field in your <code>options</code>, the <code>thresholds</code> array will wind up being simply <code>[0.0]</code>, which is likely not what you expect. Debugging chaos may ensue.</p>
</div>
<h2 id="Examples">Examples</h2>
<p><<<...>>></p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('IntersectionObserver', '#dom-intersectionobserver-thresholds', 'IntersectionObserver.thresholds')}}</td>
<td>{{Spec2('IntersectionObserver')}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("api.IntersectionObserver.thresholds")}}</p>
|