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