Skip to content

Commit 68c3a12

Browse files
authored
Merge pull request #15 from ScriptedAlchemy/rootMargin
feat: add rootMargin to intersection observer
2 parents 34e4e6b + 8e147a3 commit 68c3a12

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/index.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ const event = "hydrate";
2121

2222
const io =
2323
isBrowser && IntersectionObserver
24-
? new IntersectionObserver(entries => {
25-
entries.forEach(entry => {
26-
if (entry.isIntersecting || entry.intersectionRatio > 0) {
27-
entry.target.dispatchEvent(new CustomEvent(event));
28-
}
29-
});
30-
})
24+
? new IntersectionObserver(
25+
entries => {
26+
entries.forEach(entry => {
27+
if (entry.isIntersecting || entry.intersectionRatio > 0) {
28+
entry.target.dispatchEvent(new CustomEvent(event));
29+
}
30+
});
31+
},
32+
{
33+
rootMargin: "150px"
34+
}
35+
)
3136
: null;
3237

3338
// React currently throws a warning when using useLayoutEffect on the server.

0 commit comments

Comments
 (0)