-
Notifications
You must be signed in to change notification settings - Fork 785
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 snapGrid moves incomplete steps to respect restriction #208
Comments
I agree. I haven't thought of a good way to implement this yet. I'll keep it in mind and will try come back to it if I or anyone else comes up with something good. |
Thank you for this, but I don't understand how this helps, I already have the limit set manually in |
It's not a bug. The snap and restrict modifiers are independent and unaware of each other so there's no way for grid snapping to automatically consider restriction unless that separation is broken (which I think is a bad idea). Also, it's not always possible to ensure that both restriction and snapping are respected – what should be done if all points on the grid are outside the restriction? It's an unlikely configuration but I think it's worth considering. The Technically, it's not that snapping is applied incompletely/wrongly to respect restriction, but rather that restriction is applied after snapping and that changes the coordinates from the previous modified values. If you want to maintain a custom build, you can change the order of the modifiers in the src/index.js file or write a module that adds With these solutions, I consider the issue resolved. I'm open to any suggestions you have. |
Makes total sense. Just swapping the order would not help? Then it can maybe be the default. I understand the technical separation and I agree it should stay like it is. But when somebody uses both of them, one expects that both modifiers are respected, and that is not the case here. |
Actually, in the demo that you gave, swapping the order doesn't really help. It would just mean that the restriction wouldn't be respected instead of snapping. With different restriction and grid dimensions it could be beneficial.
I don't see any good way to make sure that all modifiers are always respected. With the possibility of new modifiers being added, I don't want to try to maintain such a guarantee. |
I edited this jsfiddle to reflect my problem.
Normally in my case
restriction: 'parent'
should be fine, because thesnap
option would not permit the object to move an incomplete step (container size is not divisible by grid size).To overcome this issue I have to build a custom hacky restriction:
In my opinion, this last move should not be allowed, since the grid AND the restriction should be respected, but at least should be a configurable option.
The text was updated successfully, but these errors were encountered: