diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
| commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
| tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/intersectionobserver | |
| parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
| download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip | |
initial commit
Diffstat (limited to 'files/ja/web/api/intersectionobserver')
5 files changed, 380 insertions, 0 deletions
diff --git a/files/ja/web/api/intersectionobserver/disconnect/index.html b/files/ja/web/api/intersectionobserver/disconnect/index.html new file mode 100644 index 0000000000..406a9c2e2a --- /dev/null +++ b/files/ja/web/api/intersectionobserver/disconnect/index.html @@ -0,0 +1,61 @@ +--- +title: IntersectionObserver.disconnect() +slug: Web/API/IntersectionObserver/disconnect +tags: + - API + - Disconnect + - Intersection Observer + - Intersection Observer API + - IntersectionObserver + - Method + - Reference + - メソッド +translation_of: Web/API/IntersectionObserver/disconnect +--- +<div>{{APIRef("Intersection Observer API")}}</div> + +<p><span class="seoSummary">{{domxref("IntersectionObserver")}} の <code><strong>disconnect()</strong></code> メソッドは、すべての対象要素について、表示状態の変化の監視を停止します。</span></p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox"><em>intersectionObserver</em>.disconnect();</pre> + +<h3 id="Parameters" name="Parameters">引数</h3> + +<p>なし。</p> + +<h3 id="Return_value" name="Return_value">返値</h3> + +<p><code>undefined</code>。</p> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('IntersectionObserver','#dom-intersectionobserver-disconnect','IntersectionObserver.disconnect()')}}</td> + <td>{{Spec2('IntersectionObserver')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("api.IntersectionObserver.disconnect")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{domxref("IntersectionObserver.observe", "observe()")}}</li> + <li>{{domxref("IntersectionObserver.unobserve", "unobserve()")}}</li> +</ul> diff --git a/files/ja/web/api/intersectionobserver/index.html b/files/ja/web/api/intersectionobserver/index.html new file mode 100644 index 0000000000..2dfa60607a --- /dev/null +++ b/files/ja/web/api/intersectionobserver/index.html @@ -0,0 +1,88 @@ +--- +title: IntersectionObserver +slug: Web/API/IntersectionObserver +tags: + - API + - Experimental + - Intersection Observer API + - IntersectionObserver + - Reference + - インターフェイス + - リファレンス + - 実験的 +translation_of: Web/API/IntersectionObserver +--- +<div>{{APIRef("Intersection Observer API")}}</div> + +<p><a href="/ja/docs/Web/API/Intersection_Observer_API">Intersection Observer API</a> の <code><strong>IntersectionObserver</strong></code> インターフェイスは、<span class="seoSummary">対象の要素と祖先要素または文書の最上位の{{Glossary('viewport', 'ビューポート')}}との交差状態の変化を非同期に監視する方法を提供します。</span>祖先要素またはビューポートがルートとして参照されます。</p> + +<p><code>IntersectionObserver</code> が生成されると、ルート内での可視部分の比率を監視するように構築されます。構成はいったん <code>IntersectionObserver</code> が生成されると変更できませんので、与えられた監視オブジェクトは可視性の観点による特定の変化を監視する場合にのみ有用です。しかしながら、同じオブザーバーで複数の対象要素を監視することができます。</p> + +<h2 id="Constructor" name="Constructor">コンストラクター</h2> + +<dl> + <dt>{{domxref("IntersectionObserver.IntersectionObserver()")}}</dt> + <dd>対象の要素の可視性が1つまたは複数の閾値を通過したことを検出したときに、指定されたコールバック関数を実行する新しい <code>IntersectionObserver</code> オブジェクトを生成します。</dd> +</dl> + +<h2 id="Properties" name="Properties">プロパティ</h2> + +<dl> + <dt>{{domxref("IntersectionObserver.root")}} {{readonlyinline}}</dt> + <dd>指定された、監視対象となる {{domxref("element")}} の祖先です。コンストラクターに値が渡されなかった場合はこの値が <code>null</code> となり、最上位の文書のビューポートが使用されます。</dd> + <dt>{{domxref("IntersectionObserver.rootMargin")}} {{readonlyinline}}</dt> + <dd>交差状態を計算するときに root の {{Glossary('bounding box', 'バウンディングボックス')}} に適用されるオフセットの矩形で、計算のために root を効果的に縮小または拡大させます。このプロパティから返る値は、内部的な要件に合わせて変化するので、コンストラクターを呼び出したときに指定したものと同じにならないことがあります。それぞれのオフセットはピクセル数 (<code>px</code>) またはパーセント値 (<code>%</code>) で表すことができます。既定値は "0px 0px 0px 0px" です。</dd> + <dt>{{domxref("IntersectionObserver.thresholds")}} {{readonlyinline}}</dt> + <dd>交差領域と監視対象のバウンディングボックス領域との比の閾値を昇順に並べたリストです。対象の通知は、対象においていずれかの閾値を通過した場合に生成されます。コンストラクターで値が渡されなければ、 0 が使用されます。</dd> +</dl> + +<h2 id="Methods" name="Methods">メソッド</h2> + +<dl> + <dt>{{domxref("IntersectionObserver.disconnect()")}}</dt> + <dd><code>IntersectionObserver</code> オブジェクトが対象を監視することを停止します。</dd> + <dt>{{domxref("IntersectionObserver.observe()")}}</dt> + <dd><code>IntersectionObserver</code> が対象の要素を監視するよう命じます。</dd> + <dt>{{domxref("IntersectionObserver.takeRecords()")}}</dt> + <dd>監視対象すべての {{domxref("IntersectionObserverEntry")}} オブジェクトの配列を返し、すべての監視を停止します。</dd> + <dt>{{domxref("IntersectionObserver.unobserve()")}}</dt> + <dd><code>IntersectionObserver</code> が特定の要素の監視を停止するよう命じます。</dd> +</dl> + +<h2 id="Examples" name="Examples">例</h2> + +<pre class="brush: js">var intersectionObserver = new IntersectionObserver(function(entries) { + // intersectionRatio が 0 の場合、対象がビューの外にあるので、 + // 何かをする必要はありません。 + if (entries[0].intersectionRatio <= 0) return; + + loadItems(10); + console.log('Loaded new items'); +}); +// 監視を開始 +intersectionObserver.observe(document.querySelector('.scrollerFooter'));</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('IntersectionObserver')}}</td> + <td>{{Spec2('IntersectionObserver')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2> + +<p class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p> + +<p>{{Compat("api.IntersectionObserver")}}</p> diff --git a/files/ja/web/api/intersectionobserver/intersectionobserver/index.html b/files/ja/web/api/intersectionobserver/intersectionobserver/index.html new file mode 100644 index 0000000000..b5533ba182 --- /dev/null +++ b/files/ja/web/api/intersectionobserver/intersectionobserver/index.html @@ -0,0 +1,88 @@ +--- +title: IntersectionObserver.IntersectionObserver() +slug: Web/API/IntersectionObserver/IntersectionObserver +tags: + - API + - Constructor + - Intersection Observer API + - IntersectionObserver + - Reference + - Visibility + - Visible +translation_of: Web/API/IntersectionObserver/IntersectionObserver +--- +<div>{{APIRef("Intersection Observer API")}}</div> + +<p><span class="seoSummary"><strong><code>IntersectionObserver()</code></strong> コンストラクタは、新しい {{domxref("IntersectionObserver")}} オブジェクトを生成します。</span> <code>rootMargin</code> は、指定されていた場合は構文が正しいかが確認され、閾値は、0.0 から 1.0 の間であるか確認され、閾値のリストは昇順に並べ替えられます。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox notranslate">var <em>observer</em> = new IntersectionObserver(<em>callback</em>[, <em>options</em>]);</pre> + +<h3 id="Parameters" name="Parameters">パラメーター</h3> + +<dl> + <dt><code>callback</code></dt> + <dd>対象の要素の比率が、閾値と交差して表示されたときに実行します。コールバックは 2 つの引数を受け取ります。 + <dl> + <dt><code>entries</code></dt> + <dd>{{domxref("IntersectionObserverEntry")}} オブジェクトの配列で、それぞれ、その閾値によって指定された割合より多くあるいは少なく表示されているかに関わらず、 1 つの交差した閾値を表します。</dd> + <dt><code>observer</code></dt> + <dd>コールバックが呼び出される {{domxref("IntersectionObserver")}} 。</dd> + </dl> + </dd> + <dt><code>options</code> {{optional_inline}}</dt> + <dd>オブザーバをカスタマイズするためのオプションオブジェクトです。 もし <code>options</code> に何も指定されていない場合、オブザーバはルートとして、余白の無い、閾値 0% のドキュメントビューポートを使用します(つまり、1px でも閾値に入ればコールバックが実行されます)。次のオプションから任意の組み合わせを利用できます。 + <dl> + <dt><code>root</code></dt> + <dd>{{domxref("Element")}} または {{domxref("Document")}} オブジェクトは、対象の祖先要素であり、これらの<span>矩形はビューポートとみなされます。対象の要素が</span> <code>root</code> の表示領域においてどの部分も表示されていなければ、見えていないことになります。</dd> + <dt><code>rootMargin</code></dt> + <dd>交差状態を計算するときに root の {{Glossary('bounding_box')}} に適用されるオフセットのセットを指定する文字列で、計算のために root を効果的に縮小または拡大させます。構文は概ね CSS の {{cssxref("margin")}} プロパティのものと同じです。margin のしくみと構文について詳しくは {{SectionOnPage("/ja/docs/Web/API/Intersection_Observer_API", "The root element and root margin")}} を御覧ください。デフォルト値は "0px 0px 0px 0px" です。</dd> + <dt><code>threshold</code></dt> + <dd>1 つの数字か、または 0.0 と 1.0 の間の数字の配列で指定し、監視対象の<span class="ILfuVd"><span class="hgKElc">矩形</span></span>の総面積に対する交差領域の比率を指定します。 0.0 に指定された場合、1px でも交差領域に入ったらその対象要素は表示されたとみなされます。threshold がどのように使われるかについては、 {{SectionOnPage("/ja/docs/Web/API/Intersection_Observer_API", "Thresholds")}} でより深く説明されています。 デフォルトの閾値は 0.0 です。</dd> + </dl> + </dd> +</dl> + +<h3 id="Return_value" name="Return_value">戻り値</h3> + +<p>新しい {{domxref("IntersectionObserver")}} は、対象要素が、指定された <code>root</code> 内で <code>threshold</code> の可視閾値を通過して表示されたかどうかの可視性を監視するために使用できます。対象要素の可視性の変更を監視し始めるには、 {{domxref("IntersectionObserver.observe", "observe()")}} メソッドを呼び出します。</p> + +<h3 id="Exceptions" name="Exceptions">例外</h3> + +<dl> + <dt><code>SyntaxError</code></dt> + <dd>指定した <code>rootMargin</code> は無効な値です。</dd> + <dt><code>RangeError</code></dt> + <dd><code>threshold</code> の値のうち 1 つまたは 1 つ以上の値が 0.0 から 1.0 の範囲に当てはまりません。</dd> +</dl> + +<h2 id="Example" name="Example">例</h2> + +<p>この例では、監視されている要素の可視範囲が 10% 以上になったときに毎回 <code>myObserverCallback</code> を呼び出すような新しい intersection observer を生成しています。</p> + +<pre class="brush: js notranslate">let observer = new IntersectionObserver(myObserverCallback, + {threshold: 0.1});</pre> + +<h2 id="Specifications" name="Specifications">仕様</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">仕様書</th> + <th scope="col">策定状況</th> + <th scope="col">コメント</th> + </tr> + <tr> + <td>{{SpecName('IntersectionObserver','#dom-intersectionobserver-intersectionobserver','IntersectionObserver constructor')}}</td> + <td>{{Spec2('IntersectionObserver')}}</td> + <td>初期定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="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.IntersectionObserver")}}</p> diff --git a/files/ja/web/api/intersectionobserver/observe/index.html b/files/ja/web/api/intersectionobserver/observe/index.html new file mode 100644 index 0000000000..edd2565bc0 --- /dev/null +++ b/files/ja/web/api/intersectionobserver/observe/index.html @@ -0,0 +1,71 @@ +--- +title: IntersectionObserver.observe() +slug: Web/API/IntersectionObserver/observe +tags: + - API + - Intersection Observer + - Intersection Observer API + - IntersectionObserver + - Method + - Reference + - observe +translation_of: Web/API/IntersectionObserver/observe +--- +<div>{{APIRef("Intersection Observer API")}}{{SeeCompatTable}}</div> + +<p><span class="seoSummary">{{domxref("IntersectionObserver")}} の <code><strong>observe()</strong></code> メソッドは、要素を <code>IntersectionObserver</code> によって監視される対象要素に追加します。各オブザーバーはそれぞれ個別の閾値とルートを持っていますが、複数の対象要素について可視部分の変化を監視できます。</span>要素の監視を停止するには、{{domxref("IntersectionObserver.unobserve()")}} を呼び出します。</p> + +<p>指定された要素の可視部分がオブザーバーの可視量の閾値を通過したとき ({{domxref("IntersectionObserver.thresholds")}} を参照)、オブザーバーのコールバックが実行されます。このコールバックは、発生した交差の変化を表す {{domxref("IntersectionObserverEntry")}} オブジェクトの配列を受け取ります。この構成によって、1回のコールバック呼び出しにつき複数の要素の交差状態の変化を処理することができます。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox"><em>IntersectionObserver</em>.observe(<em>targetElement</em>);</pre> + +<h3 id="Parameters" name="Parameters">パラメーター</h3> + +<dl> + <dt><code>targetElement</code></dt> + <dd>可視部分がルート内に収まっているかどうかが監視される{{domxref("element", "要素")}}。この要素はルート要素の子要素でなければなりません (ルートが文書のビューポートである場合、要素が現在の文書内に含まれている必要があります)。</dd> +</dl> + +<h3 id="Return_value" name="Return_value">戻り値</h3> + +<p><code>undefined</code>。</p> + +<dl> +</dl> + +<h2 id="Examples" name="Examples">例</h2> + +<p><<<...>>></p> + +<h2 id="Specifications" name="Specifications">仕様</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">仕様書</th> + <th scope="col">策定状況</th> + <th scope="col">コメント</th> + </tr> + <tr> + <td>{{SpecName('IntersectionObserver','#dom-intersectionobserver-observe','IntersectionObserver.observe()')}}</td> + <td>{{Spec2('IntersectionObserver')}}</td> + <td>初期定義</td> + </tr> + </tbody> +</table> + +<div> +<h2 id="Browser_compatibility" name="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.observe")}}</p> +</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{domxref("IntersectionObserver.unobserve()")}}</li> +</ul> diff --git a/files/ja/web/api/intersectionobserver/takerecords/index.html b/files/ja/web/api/intersectionobserver/takerecords/index.html new file mode 100644 index 0000000000..3b05186010 --- /dev/null +++ b/files/ja/web/api/intersectionobserver/takerecords/index.html @@ -0,0 +1,72 @@ +--- +title: IntersectionObserver.takeRecords() +slug: Web/API/IntersectionObserver/takeRecords +tags: + - API + - Intersection Observer + - Intersection Observer API + - IntersectionObserver + - Method + - NeedsExample + - Reference + - takeRecords + - メソッド +translation_of: Web/API/IntersectionObserver/takeRecords +--- +<div>{{APIRef("Intersection Observer API")}}</div> + +<p><span class="seoSummary">{{domxref("IntersectionObserver")}} の <code><strong>takeRecords()</strong></code> メソッドは、明示的にこのメソッドを呼び出したか、監視のコールバックで暗黙的に自動呼出しされたかのどちらかで前回交差をチェックした後で交差状態の変化があった対象要素を示す {{domxref("IntersectionObserverEntry")}} オブジェクトの配列を返します。</span></p> + +<div class="note"> +<p><strong>メモ:</strong> コールバックを使用してこれらの変更を監視している場合は、このメソッドを呼び出す必要はありません。このメソッドを呼び出すと処理待ちの交差リストをクリアしてしまうため、コールバックが実行されません。</p> +</div> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox"><em>intersectionObserverEntries</em> = <em>intersectionObserver</em>.takeRecords();</pre> + +<h3 id="Parameters" name="Parameters">引数</h3> + +<p>なし。</p> + +<h3 id="Return_value" name="Return_value">返値</h3> + +<p>前回交差をチェックした後で交差状態の変化があった対象要素を示す {{domxref("IntersectionObserverEntry")}} オブジェクトの配列です。</p> + +<dl> +</dl> + +<h2 id="Examples" name="Examples">例</h2> + +<p><<<...>>></p> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('IntersectionObserver','#dom-intersectionobserver-takerecords','IntersectionObserver.takeRecords()')}}</td> + <td>{{Spec2('IntersectionObserver')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("api.IntersectionObserver.takeRecords")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li><a href="/ja/docs/Web/API/Intersection_Observer_API">Intersection Observer API</a></li> +</ul> |
