Skip to content

Commit f578f58

Browse files
committed
Use rootMargin: -100px
1 parent a9e8abb commit f578f58

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

dotcom-rendering/src/components/FrontSectionTracker.importable.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,19 @@ export const FrontSectionTracker = () => {
7474
const callback = (entries: IntersectionObserverEntry[]) => {
7575
for (const entry of entries) {
7676
if (entry.isIntersecting) {
77-
const sectionName = entry.target.id;
78-
if (!viewedCollections.has(sectionName)) {
79-
setCollectionAsViewed(sectionName);
80-
reportViewEvent(sectionName);
77+
const collectionName = entry.target.id;
78+
if (!viewedCollections.has(collectionName)) {
79+
setCollectionAsViewed(collectionName);
80+
reportViewEvent(collectionName);
8181
observer.unobserve(entry.target);
8282
}
8383
}
8484
}
8585
};
86-
87-
const observer = new IntersectionObserver(callback);
86+
const options = {
87+
rootMargin: '-100px',
88+
};
89+
const observer = new IntersectionObserver(callback, options);
8890

8991
for (const collection of collectionElements) {
9092
observer.observe(collection);

0 commit comments

Comments
 (0)