I think jQuery's drag and drop API is using the mouse events directly and not using the built-in dragstart/etc., and that's why they can apply constraints.
I see. Thanks for the info. It seems the problem is that the item being dragged is a temporary image copy of the source element, not the source element itself. That makes controlling the position of the source element irrelevant. Needs to somehow control the position of the temporary image copy to make it work. But anyway it’s a good learning exercise. Thanks for the discussion.
1. When I get the event, I update the underlying state, but leave the DOM element alone.
2. I can apply constraints to that state. To restrict dragging to the x-axis, I would never change y.
3. I use the state to drive the redisplay of the DOM element.
Some examples of constraints I want: https://www.redblobgames.com/articles/curved-paths/making-of...
I think jQuery's drag and drop API is using the mouse events directly and not using the built-in dragstart/etc., and that's why they can apply constraints.