react-native-draggable icon indicating copy to clipboard operation
react-native-draggable copied to clipboard

Draggable with Grid

Open Crashtor opened this issue 4 years ago • 0 comments

To add grid or grid-like snap functionality I made a modification to the Draggable.js

in the handleOnDrag on line 124 I added

const changeX = clamp(
     Math.round(dx /25) * 25,
     ...
)

and

const changeY = clamp(
     Math.round(dy / 25) * 25,
     ...
)

(Values can be changed depending on grid-size, 25 being a 25px grid)

Although the behavior is as expected, it feels a bit too "snappy" — Any suggestions on how I could modify it to transition to each new grid slot instead of instantly snap to each new grid slot?

Thanks

Crashtor avatar May 25 '21 22:05 Crashtor