Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draggable with Grid #97

Open
Crashtor opened this issue May 25, 2021 · 0 comments
Open

Draggable with Grid #97

Crashtor opened this issue May 25, 2021 · 0 comments

Comments

@Crashtor
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant