Skip to content

Commit 76405d7

Browse files
authored
fix: ensure thresholds is defined (#415)
Sometimes the thresholds value on the IntersectionObserver instance could be undefined. Add a fallback to a default value in the cases where the browser doesn't set it. This fixes #414
1 parent 9312d1d commit 76405d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/observers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function createObserver(options: IntersectionObserverInit) {
5757
// -Firefox ignores `threshold` when considering `isIntersecting`, so it will never be false again if `threshold` is > 0
5858
const inView =
5959
entry.isIntersecting &&
60-
observer.thresholds.some(
60+
(observer.thresholds ?? [0]).some(
6161
(threshold) => entry.intersectionRatio >= threshold,
6262
);
6363

0 commit comments

Comments
 (0)