fix: events can not be dragged back to their original location #847
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When you start dragging an event on any views it works fine, but then when you try to move it back to the original position it skips over it (you can try this in the kitchen sink).
The problem appeared when the threshold for differentiating between a drag and a click (with clumsy minor drag) has been introduced. Returning the event to the original position causes the validateDrag function to return false. To solve this I introduced a dragAlreadyMoved field which turns to true when a single dragging event has happened (meaning that it has been over the threshold at least once). When the dragAlreadyMoved flag is true we no longer care about the threshold. This had to be implemented for week view normal events and all day events and for day view events. I fixed the daily scheduler demo aswell.
I tried a few ways of solving the problem.
By saving the previous drag position and comparing to that but it required way more work in the components.
I tried using local variables (in closure scope) instead of fields for dragAlreadyMoved but it was less clear.
An alternative solution could be modifying the draggable library to call the validateDrag function with the x-y coordinates which would be used in the not snapping mode instead of the snap coordinates, but that could probably break many things because it seems really fundamental to how the draggable library works.