Skip to content

Instantly share code, notes, and snippets.

@becca-bailey
Last active May 2, 2020 03:48
Show Gist options
  • Save becca-bailey/f1479638f5d6fdbaffd82d926861b68a to your computer and use it in GitHub Desktop.
Save becca-bailey/f1479638f5d6fdbaffd82d926861b68a 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 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