Last active
May 2, 2020 03:48
-
-
Save becca-bailey/f1479638f5d6fdbaffd82d926861b68a 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 bubbleMachine = Machine({ | |
id: "bubble", | |
initial: "initial", | |
context: { | |
x: 0, | |
y: 0, | |
r: 0, | |
name: "", | |
id: "" | |
}, | |
states: { | |
initial: { | |
on: { | |
MOUSE_ENTER: { | |
target: "hovered", | |
actions: [ | |
sendParent(ctx => ({ type: "BUBBLE.MOUSE_ENTER", bubble: ctx })) | |
] | |
} | |
} | |
}, | |
hovered: { | |
on: { | |
MOUSE_LEAVE: { | |
target: "initial", | |
actions: [ | |
sendParent(ctx => ({ type: "BUBBLE.MOUSE_LEAVE", bubble: ctx })) | |
] | |
}, | |
CLICK: "pinned" | |
} | |
}, | |
pinned: { | |
on: { | |
CLICK: { | |
target: "hovered", | |
actions: [sendParent(ctx => ({ type: "BUBBLE.CLICK", bubble: ctx }))] | |
}, | |
MOUSE_LEAVE: {} | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment