1
0
Fork 0
mirror of synced 2024-07-13 02:05:54 +12:00

Fix issue where grid highlighted rows are incorrect when page is scrolled

This commit is contained in:
Andrew Kingston 2024-06-10 09:40:08 +01:00
parent 08a48a9ff9
commit 7566ecfac8

View file

@ -23,14 +23,24 @@
0
)
const updateBounds = () => {
bounds.set(body.getBoundingClientRect())
}
onMount(() => {
// Observe and record the height of the body
const observer = new ResizeObserver(() => {
bounds.set(body.getBoundingClientRect())
})
observer.observe(body)
const resizeObserver = new ResizeObserver(updateBounds)
resizeObserver.observe(body)
// Capture any wheel events on the page to ensure our scroll offset is
// correct. We don't care about touch events as we only need this for
// hovering over rows with a mouse.
window.addEventListener("wheel", updateBounds, true)
// Clean up listeners
return () => {
observer.disconnect()
resizeObserver.disconnect()
window.removeEventListener("wheel", updateBounds, true)
}
})
</script>