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

createSnapModifier should use Math.round instead of Math.ceil #1403

Open
valtism opened this issue May 15, 2024 · 0 comments
Open

createSnapModifier should use Math.round instead of Math.ceil #1403

valtism opened this issue May 15, 2024 · 0 comments

Comments

@valtism
Copy link

valtism commented May 15, 2024

Was trying to figure out why my cursor felt off when trying to create a draggable card on a grid:

Screen.Recording.2024-05-15.at.3.30.27.PM.mov

I found out that it was because createSnapModifier uses Math.ceil in its calculation. https://github.com/clauderic/dnd-kit/blob/master/packages/modifiers/src/createSnapModifier.ts

Changing this to Math.round gives the drag handle the feel that it is being used by the cursor, instead of floating off to the bottom right of it. See the fixed version:

Screen.Recording.2024-05-15.at.3.29.59.PM.mov
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