Last active
October 11, 2019 12:02
-
-
Save timdeschryver/f8ded4c4d9d89096ec6a346d57005d15 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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
| const dragMachine = Machine( | |
| { | |
| key: 'ngx-drag-to-select', | |
| initial: 'clickMode', | |
| context: { | |
| shortcuts: {}, | |
| selectWithShortcut: false, | |
| x1: 0, | |
| y1: 0, | |
| x2: 0, | |
| y2: 0, | |
| selectedDirectiveIds: [] | |
| }, | |
| states: { | |
| clickMode: { | |
| on: { | |
| click: [ | |
| { | |
| actions: ['clickItemAppend'], | |
| cond: 'appendItem' | |
| }, | |
| { | |
| actions: ['clickItem'] | |
| } | |
| ] | |
| } | |
| }, | |
| dragMode: { | |
| initial: 'idle', | |
| states: { | |
| idle: { | |
| on: { | |
| mousedown: { | |
| target: 'dragging', | |
| actions: ['clearSelection', 'startDrag'] | |
| } | |
| } | |
| }, | |
| dragging: { | |
| on: { | |
| mousemove: { | |
| actions: ['drag', 'drawSelectbox', 'updateSelectedItems'] | |
| }, | |
| mouseup: { target: 'idle', actions: ['resetDrag', 'drawSelectbox'] } | |
| } | |
| } | |
| } | |
| }, | |
| selectMode: { | |
| on: { | |
| click: { | |
| actions: ['clickItemAppend'] | |
| } | |
| } | |
| }, | |
| shortcutMode: { | |
| on: { | |
| click: { | |
| actions: ['clickItemAppend'], | |
| cond: 'isShortcutPressed' | |
| } | |
| } | |
| }, | |
| disabled: {} | |
| }, | |
| on: { | |
| toggleDragMode: 'dragMode', | |
| toggleSelectMode: 'selectMode', | |
| toggleClickMode: 'clickMode', | |
| toggleSelectWithShortcut: 'shortcutMode', | |
| toggleDisabledMode: 'disabled', | |
| selectItems: { | |
| actions: 'selectItems' | |
| }, | |
| clearAll: { | |
| actions: 'clearAll' | |
| } | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment