Skip to content

Instantly share code, notes, and snippets.

@queckezz
Created January 27, 2020 16:36
Show Gist options
  • Save queckezz/7aed2cc0ea0f0375af8f5d99aca24352 to your computer and use it in GitHub Desktop.
Save queckezz/7aed2cc0ea0f0375af8f5d99aca24352 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
id: 'drag',
initial: 'idle',
context: {
item: null,
bounds: new DOMRect(),
x: 0,
y: 0
},
states: {
idle: {
on: {
DRAG: {
target: 'dragging',
actions: assign({
item: (_, ev) => ev.item,
bounds: (_, ev) => ev.bounds
})
}
}
},
returning: {
on: {
RETURN: 'idle'
}
},
dragging: {
on: {
CANCEL: 'returning',
CAN_DROP: 'droppable'
}
},
droppable: {
on: {
DROP: 'idle',
CANT_DROP: 'dragging'
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment