1
0
Fork 0
mirror of synced 2024-09-20 11:27:56 +12:00

Round grid scroll wrapper offsets to the nearest pixel

This commit is contained in:
Andrew Kingston 2024-06-27 15:51:57 +01:00
parent 8e83046321
commit c62e6d776c
No known key found for this signature in database

View file

@ -27,9 +27,11 @@
$: style = generateStyle($scroll, $rowHeight)
const generateStyle = (scroll, rowHeight) => {
const offsetX = scrollHorizontally ? -1 * scroll.left : 0
const offsetY = scrollVertically ? -1 * (scroll.top % rowHeight) : 0
return `transform: translate3d(${offsetX}px, ${offsetY}px, 0);`
const offsetX = Math.round(scrollHorizontally ? -1 * scroll.left : 0)
const offsetY = Math.round(
scrollVertically ? -1 * (scroll.top % rowHeight) : 0
)
return `transform: translate(${offsetX}px, ${offsetY}px);`
}
// Handles a mouse wheel event and updates scroll state