回答編集履歴
1
修正、加筆
answer
CHANGED
@@ -15,7 +15,15 @@
|
|
15
15
|
``` javascript
|
16
16
|
const observer = new IntersectionObserver((entries) => {
|
17
17
|
for (const entry of entries) {
|
18
|
+
if (entry.isIntersecting) {
|
18
|
-
|
19
|
+
entry.target.style.background = "red";
|
20
|
+
}
|
19
21
|
}
|
20
22
|
}, options);
|
21
|
-
```
|
23
|
+
```
|
24
|
+
|
25
|
+
`isIntersecting` は `IntersectionObserverEntry` のプロパティとなりますので、判定する場合 `entry.isIntersecting` を使用してください。
|
26
|
+
|
27
|
+
- `entry` : `IntersectionObserverEntry`
|
28
|
+
- `entry.target` : `Element`
|
29
|
+
- `entry.target.id` : `DOMString`
|