react-draggable
react-draggable copied to clipboard
Draggable not adhering to correct grid on different scales
I am using the grid and scale together in a component. However, when I want zoom in (so the scale prop changes), the component does not adhere to the grid for scale 1 but for the current scale. For example, I am using [25, 25] as grid and the scale changes as I zoom in and out. At scale=1, it works perfectly. At scale=0.5, it will use a grid of [12.5, 12.5] with respect to scale=1. At scale=2, it will use a grid of [50, 50] with respect to scale=1.
I think that the draggable component should adhere to the grid at scale=1 at all scales. So, at scale=0.5, it should move 50 pixels, instead of 25, since that would account for the change in scale. This could be implemented by setting the grid to [x * scale, y * scale], instead of [x, y].
I ended up resolving it by multiplying the grid by the scale. However, I think that this should be done by the component, rather than by the user.