-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Grid Snap Not Working? #31
Comments
Can you make svelte REPL of this example please? |
I figured it out! I interpreted the grid array to be the number of grid divisions (i.e. a 2x2 grid), not the pixel dimensions of each grid block (i.e. an infinite grid with snap points every 2px vertically and 2px horizontally). I would clarify that in the docs for other naive users. |
Thanks, ill update the docs |
I did encounter a second, somewhat related issue though: When using a defined grid, I can't move an item back to its original position. If I move an item from its [0, 0] position, I can't move it back to that origin. Am I not setting something correctly? |
Yur right, it's definitely a bug. I'll look into it. |
Thanks for checking it out. I also noticed that when dragging two items on top of each other, they can end up having very slightly different translation distances (different by ~1px or less than a pixel). I think this is a subpixel calculation/rendering difference across browsers. I was trying to detect if two elements were overlapping after a drag event (so I could move one of them out of the way), but I wasn't getting consistent results when I dragged items on top of each other. This might be easier if the So, if the user provides a grid of [50, 50] in a bounded container that has a width of 250px, and a height of 150px, you might get coordinates that look like this:
Then a user could store the coordinates returned from the What do you think? |
Seems good to me. I think I can expose a domRect property in all the events |
Should be fixed now. About the domRect, I will make a release soon with the fix and this feature included |
Released in 2.5.0 |
Hey, love the clean API on this package!
Just having some trouble getting grid-snapping to work. Can you provide an example, or elucidate what might be wrong with the following code? I'm not seeing any snap behavior change with or without the grid options provided in the DragOptions object.
![image](https://user-images.githubusercontent.com/65916939/150537036-9c2cf0a8-d867-444d-a5c2-915cabd576bf.png)
The text was updated successfully, but these errors were encountered: