IntersectionObserverEntry.target

IntersectionObserverEntry インターフェイスの読み取り専用の target プロパティは、どの対象の Element で交差ルートとの交差量が変化したかを示します。

IntersectionObserverEntrytarget プロパティは、以前に IntersectionObserver.observe() を呼び出して対象とした要素の中で、ルートとの交差が変化した要素を指定します。

この単純な例では、対象となるそれぞれの要素の opacity が、その intersectionRatio に設定されます。

js

function intersectionCallback(entries) {
  entries.forEach((entry) => {
    entry.target.opacity = entry.intersectionRatio;
  });
}

より具体的な例については、交差状態の変化の扱いをご覧ください。

仕様書

Specification
Intersection Observer
# dom-intersectionobserverentry-target

ブラウザーの互換性

BCD tables only load in the browser