In experiment #119, I worked out resizing elements. The resize happens at a single pixel resolution. But often you want to resize based on a grid.
It turns out, all it takes is rounding to the nearest grid position:
const gridSize = 10
function snapToGrid(width) }
return Math.round(width / gridSize) * gridSize
}
Code
https://svelte.dev/repl/c7ae142262d9430889e4c4e2a46e707c?version=3.37.0