Skip to content

Instantly share code, notes, and snippets.

@jcdickinson
Created July 1, 2021 22:14
Show Gist options
  • Save jcdickinson/a417faa190a2a60055eb14a3c093cc5d to your computer and use it in GitHub Desktop.
Save jcdickinson/a417faa190a2a60055eb14a3c093cc5d to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
initial: "init",
context: {
element: null,
pointerId: 0,
startX: 0,
startY: 0,
transform: null,
},
invoke: {
src: "capturePointer",
},
states: {
init: {
on: {
pointermove: {
target: "dragging",
cond: "minimumDistance",
},
pointerup: {
target: "cancel",
cond: "pointerMatches",
},
},
},
dragging: {
on: {
pointerup: {
target: "drop",
cond: "pointerMatches",
},
pointermove: {
target: "dragging",
cond: "pointerMatches",
actions: "updateTransform",
},
},
},
drop: {
type: "final",
entry: ["clearTransform", "preventDefault", "respondDrop"],
},
cancel: {
type: "final",
entry: "clearTransform",
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment