Created
January 27, 2020 16:36
-
-
Save queckezz/7aed2cc0ea0f0375af8f5d99aca24352 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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