fix: use resizeobserver instead of intersection observer (#585)
This commit is contained in:
1 parent
761f7c9ac2
commit
79d80e636d
2 files changed
+10
-15
No files matched your search
@@ -19,17 +19,14 @@
|
|||||||
}, 100)
|
}, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IntersectionObserver to watch for shifts
|
const observer = new ResizeObserver(entries => {
|
||||||
const observer = new IntersectionObserver(
|
|
||||||
entries => {
|
|
||||||
entries.forEach(entry => {
|
entries.forEach(entry => {
|
||||||
if (entry.isIntersecting && offsetEl) {
|
if (offsetEl) {
|
||||||
initialOffset = entry.boundingClientRect.top + window.scrollY
|
initialOffset =
|
||||||
|
entry.target.getBoundingClientRect().top + window.scrollY
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
})
|
||||||
{ threshold: [0, 1] },
|
|
||||||
)
|
|
||||||
|
|
||||||
if (offsetEl) observer.observe(offsetEl)
|
if (offsetEl) observer.observe(offsetEl)
|
||||||
return () => observer.disconnect()
|
return () => observer.disconnect()
|
||||||
|
|||||||
@@ -137,16 +137,14 @@
|
|||||||
})
|
})
|
||||||
}).observe(feed, { childList: true, subtree: false })
|
}).observe(feed, { childList: true, subtree: false })
|
||||||
|
|
||||||
const offsetObserver = new IntersectionObserver(
|
const offsetObserver = new ResizeObserver(entries => {
|
||||||
entries => {
|
|
||||||
entries.forEach(entry => {
|
entries.forEach(entry => {
|
||||||
if (entry.isIntersecting && listEl) {
|
if (listEl) {
|
||||||
initialOffset = entry.boundingClientRect.top + window.scrollY
|
initialOffset =
|
||||||
|
entry.target.getBoundingClientRect().top + window.scrollY
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
})
|
||||||
{ threshold: [0, 1] },
|
|
||||||
)
|
|
||||||
|
|
||||||
if (listEl) offsetObserver.observe(listEl)
|
if (listEl) offsetObserver.observe(listEl)
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
Reference in new issue
Block a user