Skip to content

Instantly share code, notes, and snippets.

@erikras
Last active July 20, 2022 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save erikras/6ff05b36083b8c9404c0c58b68c81c5b to your computer and use it in GitHub Desktop.
Save erikras/6ff05b36083b8c9404c0c58b68c81c5b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'labelEditing',
initial: 'idle',
context: {x:400,y:400},
states: {
idle: {
on: {
ADD_LAYER: {
target: 'selection',
actions: 'addLayer',
},
DRAG_START: {
target: 'dragging',
actions: 'dragStart',
},
EDIT_START: {
target: 'editing',
actions: 'writeSelection',
},
SELECT_LAYER: {
target: 'selection',
actions: 'writeSelection',
},
},
},
dragging: {
on: {
MOUSE_UP: {
target: 'selection',
actions: 'dragEnd',
},
MOUSE_MOVE: {
target: 'dragging',
actions: 'drag',
},
},
},
editing: {
on: {
UPDATE_TEXT: {target: 'selection', actions: 'updateText'},
},
},
resizing: {
on: {
MOUSE_UP: {target: 'selection', actions: 'resizeEnd'},
MOUSE_MOVE: {
target: 'resizing',
actions: 'resize',
},
},
},
selection: {
on: {
ADD_LAYER: {
target: 'selection',
actions: 'addLayer',
},
ARROW_KEY: {
target: 'selection',
actions: 'arrowKey',
},
CANCEL: {target: 'idle', actions: 'clearContext'},
DRAG_START: {
target: 'dragging',
actions: 'dragStart',
},
EDIT_START: {
target: 'editing',
actions: 'editStart',
},
RESIZE_START: {target: 'resizing', actions: 'resizeStart'},
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment