--- title: IntersectionObserver.root slug: Web/API/IntersectionObserver/root translation_of: Web/API/IntersectionObserver/root ---
{{APIRef("Intersection Observer API")}}

{{domxref("IntersectionObserver")}} 인터페이스의 read-only 속성인 root는 옵저버의 타겟 엘리먼트가 속한 화면의 경계, 즉 {{Glossary("viewport")}}의 {{Glossary("bounding box")}} 처럼 취급되는 {{domxref("Element")}} 이나 {{domxref("Document")}} 를 식별합니다. 만일 rootnull 이라면 화면 경계는 실제 document viewport가 사용됩니다.

문법

var root = intersectionObserver.root;

Value

{{domxref("Element")}} 이나 {{domxref("Document")}} 객체로, 해당 객체의 bounding box는 observer에 의해 관찰되는 대상 요소가 화면상에 얼마나 보여지는가를 가늠할 뷰포트의 경계로 사용됩니다.

사각형 경계의 교차성, {{domxref("IntersectionObserver.IntersectionObserver", "IntersectionObserver()")}} 객체 생성시에 설정된 임의의 margin에 의한 offset, 대상 요소의 경계에서 타겟 요소와 겹쳐진 모든 요소나 다른 객체의 경계를 제외한 것이 대상 요소의 가시성 계산에 고려됩니다.

만일 rootnull이라면 현재 document가 root로 사용되며, 그것의 viewport의 경계(즉 document의 노출 영역)가 root 의 경계로 사용됩니다.

사용예

이 예제는 intersection observer의 root 요소의 {{cssxref("border")}}를 2픽셀 너비의 녹색 라인으로 설정합니다.

observer.root.style.border = "2px solid #44aa44";

Specifications

Specification Status Comment
{{SpecName('IntersectionObserver', '#dom-intersectionobserver-root', 'IntersectionObserver')}} {{Spec2('IntersectionObserver')}} Initial definition

Browser compatibility

{{Compat("api.IntersectionObserver.root")}}

See also