Use context
to update the extended state of the drag/drop state machine. You will need to:
- Assign the point values (
px
,py
) to wherever the#box
was clicked on theidle (mousedown) -> dragging
transition. - Assign the delta values (
dx
,dy
) to how far from the originalpx
andpy
values the mouse has moved on thedragging (mousemove)
transition. - Assign the resting position (
x
,y
) as the current position + the delta on thedragging (mouseup) -> idle
transition.
- Start with inline assign action objects created from
assign(...)
. - Refactor these ouside the machine.
- Set these as configurable actions in
options.actions
.
- Listen for
keyup
events on the body. WhenEscape
is pressed, we should cancel dragging and reset the box to its original position. Where would this transition go?