Skip to content

Commit 4e8be38

Browse files
authored
fix: adjust intersection observer threshold for sticky class toggle (#2637)
1 parent b960519 commit 4e8be38

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/core/event/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ export function Events(Base) {
5757
return;
5858
}
5959

60-
const observer = new IntersectionObserver(entries => {
61-
const isIntersecting = entries[0].isIntersecting;
62-
const op = isIntersecting ? 'remove' : 'add';
60+
const observer = new IntersectionObserver(
61+
entries => {
62+
const isIntersecting = entries[0].isIntersecting;
63+
const op = isIntersecting ? 'remove' : 'add';
6364

64-
dom.body.classList[op]('sticky');
65-
});
65+
dom.body.classList[op]('sticky');
66+
},
67+
{ threshold: 0.01 },
68+
);
6669

6770
observer.observe(coverElm);
6871
}

0 commit comments

Comments
 (0)