1
0
Fork 0
mirror of synced 2024-08-05 13:21:26 +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 0
) )
const updateBounds = () => {
bounds.set(body.getBoundingClientRect())
}
onMount(() => { onMount(() => {
// Observe and record the height of the body // Observe and record the height of the body
const observer = new ResizeObserver(() => { const resizeObserver = new ResizeObserver(updateBounds)
bounds.set(body.getBoundingClientRect()) resizeObserver.observe(body)
})
observer.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 () => { return () => {
observer.disconnect() resizeObserver.disconnect()
window.removeEventListener("wheel", updateBounds, true)
} }
}) })
</script> </script>