回答編集履歴
1
追記
test
CHANGED
@@ -1,3 +1,19 @@
|
|
1
1
|
> <div class="sample filp">
|
2
2
|
|
3
3
|
「filp」と「flip」が混在しています
|
4
|
+
|
5
|
+
1回だけ処理するならクラスのremoveはいらないともいます
|
6
|
+
```javascript
|
7
|
+
window.addEventListener('DOMContentLoaded', ()=>{
|
8
|
+
const observer = new IntersectionObserver(entries => {
|
9
|
+
entries.forEach(entry => {
|
10
|
+
if (entry.intersectionRatio > 0) {
|
11
|
+
entry.target.classList.add('sample-animation');
|
12
|
+
}
|
13
|
+
});
|
14
|
+
});
|
15
|
+
document.querySelectorAll('.sample').forEach(target=>{
|
16
|
+
observer.observe(target);
|
17
|
+
});
|
18
|
+
});
|
19
|
+
```
|