fix: adjust intersection observer threshold for sticky class toggle (#2637)

This commit is contained in:
Luffy 2025-12-04 14:01:59 +08:00 committed by GitHub
parent b960519608
commit 4e8be38304
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -57,12 +57,15 @@ export function Events(Base) {
return;
}
const observer = new IntersectionObserver(entries => {
const isIntersecting = entries[0].isIntersecting;
const op = isIntersecting ? 'remove' : 'add';
const observer = new IntersectionObserver(
entries => {
const isIntersecting = entries[0].isIntersecting;
const op = isIntersecting ? 'remove' : 'add';
dom.body.classList[op]('sticky');
});
dom.body.classList[op]('sticky');
},
{ threshold: 0.01 },
);
observer.observe(coverElm);
}