回答編集履歴
2
例追加
test
CHANGED
@@ -19,3 +19,31 @@
|
|
19
19
|
```
|
20
20
|
|
21
21
|
[https://www.w3.org/TR/cssom-view-1/#dom-document-elementfrompoint](https://www.w3.org/TR/cssom-view-1/#dom-document-elementfrompoint)
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
IntersectionObserver の例
|
26
|
+
|
27
|
+
```jQuery
|
28
|
+
|
29
|
+
const observer = new IntersectionObserver((entries, observer) => {
|
30
|
+
|
31
|
+
const entry = entries.find(a => a.isIntersecting);
|
32
|
+
|
33
|
+
if (entry) {
|
34
|
+
|
35
|
+
const id = entry.target.id;
|
36
|
+
|
37
|
+
$('nav li a[href="#' + id + '"]').closest('li').addClass('selected').siblings().removeClass('selected');
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
}, { rootMargin: '-50%' });
|
42
|
+
|
43
|
+
$('section[id]').each((index, element) => observer.observe(element));
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
[https://developer.mozilla.org/ja/docs/Web/API/Intersection_Observer_API](https://developer.mozilla.org/ja/docs/Web/API/Intersection_Observer_API)
|
1
不要個所削除
test
CHANGED
@@ -19,7 +19,3 @@
|
|
19
19
|
```
|
20
20
|
|
21
21
|
[https://www.w3.org/TR/cssom-view-1/#dom-document-elementfrompoint](https://www.w3.org/TR/cssom-view-1/#dom-document-elementfrompoint)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
elementFromPoint
|