aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/intersectionobserver/thresholds
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/intersectionobserver/thresholds
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/intersectionobserver/thresholds')
-rw-r--r--files/zh-cn/web/api/intersectionobserver/thresholds/index.html52
1 files changed, 52 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/intersectionobserver/thresholds/index.html b/files/zh-cn/web/api/intersectionobserver/thresholds/index.html
new file mode 100644
index 0000000000..22fa1f96d8
--- /dev/null
+++ b/files/zh-cn/web/api/intersectionobserver/thresholds/index.html
@@ -0,0 +1,52 @@
+---
+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>&lt;&lt;&lt;...&gt;&gt;&gt;</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 class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("api.IntersectionObserver.thresholds")}}</p>