Skip to content

Commit 2f3562d

Browse files
committed
Refactor intersection observer logic for better performance and accessibility
1 parent 23aa360 commit 2f3562d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/App.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ function App() {
1515
'(prefers-reduced-motion: reduce)'
1616
).matches;
1717

18-
if (prefersReducedMotion) {
18+
if (
19+
prefersReducedMotion ||
20+
!('IntersectionObserver' in window)
21+
) {
1922
elements.forEach((element) => element.classList.add('is-visible'));
2023
return undefined;
2124
}
@@ -29,7 +32,7 @@ function App() {
2932
}
3033
});
3134
},
32-
{ threshold: 0.18, rootMargin: '0px 0px -10% 0px' }
35+
{ threshold: 0.01, rootMargin: '0px 0px -8% 0px' }
3336
);
3437

3538
elements.forEach((element) => observer.observe(element));

0 commit comments

Comments
 (0)