aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/intersectionobserver/observe/index.md
diff options
context:
space:
mode:
Diffstat (limited to 'files/ko/web/api/intersectionobserver/observe/index.md')
-rw-r--r--files/ko/web/api/intersectionobserver/observe/index.md85
1 files changed, 85 insertions, 0 deletions
diff --git a/files/ko/web/api/intersectionobserver/observe/index.md b/files/ko/web/api/intersectionobserver/observe/index.md
new file mode 100644
index 0000000000..5c10623363
--- /dev/null
+++ b/files/ko/web/api/intersectionobserver/observe/index.md
@@ -0,0 +1,85 @@
+---
+title: IntersectionObserver.observe()
+slug: Web/API/IntersectionObserver/observe
+translation_of: Web/API/IntersectionObserver/observe
+---
+<div>{{APIRef("Intersection Observer API")}}{{SeeCompatTable}}</div>
+
+<p><span class="seoSummary">The {{domxref("IntersectionObserver")}} <code><strong>observe()</strong></code> 메서드는 <code>IntersectionObserver</code> 객체가 관찰할 엘리먼트 목록에 단일 엘리먼트를 추가합니다. 하나의 옵저버 객체는 단일한 threshold와 root를 가지지만 복수의 타겟 엘리먼트의 가시성 변화를 관찰할 수 있습니다.</span> 만일 엘리먼트 관찰을 중지하고 싶다면 {{domxref("IntersectionObserver.unobserve()")}} 메서드를 호출하세요.</p>
+
+<p>특정 엘리먼트의 가시성이 다른 옵저버의 가시성 threshold와 교차할 때({{domxref("IntersectionObserver.thresholds")}} 참조), 옵저버 콜백은 발생한 교차성 변경을 알리는 {{domxref("IntersectionObserverEntry")}} 객체와 함께 실행됩니다.</p>
+
+<p>노트. 이 디자인은 복수 엘리먼트의 교차성 변경이 하나의 콜백 실행을 통해 처리되는 것을 허용합니다.</p>
+
+<h2 id="문법">문법</h2>
+
+<pre class="syntaxbox"><em>IntersectionObserver</em>.observe(<em>targetElement</em>);</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>targetElement</code></dt>
+ <dd>가시성이 감시될 root 내부의 {{domxref("element")}}. 해당 엘리먼트는 루트 엘리먼트의 자손 노드여야 합니다(혹은 현재 root가 document의 viewport일 때는 현재 document 내부의 엘리먼트여야 합니다).</dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p><code>undefined</code>.</p>
+
+<dl>
+</dl>
+
+<h2 id="Examples">Examples</h2>
+
+<p>IntersectionObserver 를 등록한다</p>
+
+<pre>
+// IntersectionObserver 를 등록한다.
+const io = new IntersectionObserver(entries => {
+ entries.forEach(entry => {
+ // 관찰 대상이 viewport 안에 들어온 경우 'tada' 클래스를 추가
+ if (entry.intersectionRatio > 0) {
+ entry.target.classList.add('tada');
+ }
+ // 그 외의 경우 'tada' 클래스 제거
+ else {
+ entry.target.classList.remove('tada');
+ }
+ })
+})
+
+// 관찰할 대상을 선언하고, 해당 속성을 관찰시킨다.
+const boxElList = document.querySelectorAll('.box');
+boxElList.forEach((el) => {
+ io.observe(el);
+})
+</pre>
+
+<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-observe','IntersectionObserver.observe()')}}</td>
+ <td>{{Spec2('IntersectionObserver')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<div>
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("api.IntersectionObserver.observe")}}</p>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{domxref("IntersectionObserver.unobserve()")}}</li>
+</ul>