Skip to content

Commit d200424

Browse files
Wired the reposition states together
1 parent 537bd66 commit d200424

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

‎packages/atri-app-core/src/canvasMachine.ts‎

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ const focused = "focused" as const;
109109
const unfocused = "unfocused" as const;
110110
const selectIdle = "selectIdle" as const;
111111
const hoverWhileSelected = "hoverWhileSelected" as const;
112+
const repositionIdle = "repositionIdle" as const;
113+
const repositionActive = "repositionActive" as const;
112114

113115
// context
114116

@@ -323,12 +325,24 @@ export function createCanvasMachine(id: string) {
323325
},
324326
states: {
325327
[initial]: {
328+
entry: (context) => {
329+
console.log("Entered Initial State", context);
330+
},
331+
exit: (context) => {
332+
console.log("Exited Initial State", context);
333+
},
326334
on: {
327335
[IFRAME_DETECTED]: { target: checks_completed },
328336
[TOP_WINDOW_DETECTED]: { target: noop },
329337
},
330338
},
331339
[checks_completed]: {
340+
entry: (context) => {
341+
console.log("Entered checks_completed State", context);
342+
},
343+
exit: (context) => {
344+
console.log("Exited checks_completed State", context);
345+
},
332346
on: {
333347
[WINDOW_LOADED]: { target: ready, actions: ["emitReady"] },
334348
},
@@ -337,6 +351,12 @@ export function createCanvasMachine(id: string) {
337351
initial: idle,
338352
states: {
339353
[idle]: {
354+
entry: (context) => {
355+
console.log("Entered Ready Idle State", context);
356+
},
357+
exit: (context) => {
358+
console.log("Exited Ready Idle State", context);
359+
},
340360
on: {
341361
[MOUSE_MOVE]: {
342362
target: hover,
@@ -353,10 +373,12 @@ export function createCanvasMachine(id: string) {
353373
[hover]: {
354374
entry: (context, event) => {
355375
callSubscribers("hover", context, event);
376+
console.log("Entered Ready Hover State", context);
356377
},
357378
exit: (context, event) => {
358379
context.hovered = null;
359380
callSubscribers("hoverEnd", context, event);
381+
console.log("Exited Ready Hover State", context);
360382
},
361383
on: {
362384
[MOUSE_MOVE]: {
@@ -376,6 +398,12 @@ export function createCanvasMachine(id: string) {
376398
},
377399
},
378400
[pressed]: {
401+
entry: (context) => {
402+
console.log("Entered Ready Pressed State", context);
403+
},
404+
exit: (context) => {
405+
console.log("Exited Ready Pressed State", context);
406+
},
379407
on: {
380408
[MOUSE_UP]: {
381409
target: selected,
@@ -390,6 +418,7 @@ export function createCanvasMachine(id: string) {
390418
exit: (context, event) => {
391419
callSubscribers("selectEnd", context, event);
392420
context.selected = null;
421+
console.log("Exited Ready Selected State", context);
393422
},
394423
on: {
395424
[MOUSE_DOWN]: {
@@ -405,9 +434,11 @@ export function createCanvasMachine(id: string) {
405434
[focused]: {
406435
entry: (context, event) => {
407436
callSubscribers("focus", context, event);
437+
console.log("Entered focusstates Focused", context);
408438
},
409439
exit: (context, event) => {
410440
callSubscribers("focusEnd", context, event);
441+
console.log("Exited focusstates Focused", context);
411442
},
412443
on: {
413444
[BLUR]: {
@@ -424,6 +455,18 @@ export function createCanvasMachine(id: string) {
424455
initial: selectIdle,
425456
states: {
426457
[selectIdle]: {
458+
entry: (context) => {
459+
console.log(
460+
"Entered hoverstates selectIdle State",
461+
context
462+
);
463+
},
464+
exit: (context) => {
465+
console.log(
466+
"Exited hoverstates selectIdle State",
467+
context
468+
);
469+
},
427470
on: {
428471
[MOUSE_OVER]: {
429472
target: hoverWhileSelected,
@@ -432,6 +475,18 @@ export function createCanvasMachine(id: string) {
432475
},
433476
},
434477
[hoverWhileSelected]: {
478+
entry: (context) => {
479+
console.log(
480+
"Entered hoverstates hoverWhileSelected State",
481+
context
482+
);
483+
},
484+
exit: (context) => {
485+
console.log(
486+
"Exited hoverstates hoverWhileSelected State",
487+
context
488+
);
489+
},
435490
on: {
436491
[MOUSE_OVER]: {
437492
target: hoverWhileSelected,
@@ -443,6 +498,39 @@ export function createCanvasMachine(id: string) {
443498
},
444499
},
445500
},
501+
repositionstates: {
502+
initial: repositionIdle,
503+
states: {
504+
[repositionIdle]: {
505+
entry: (context) => {
506+
console.log(
507+
"Entered repositionstates repositionIdle",
508+
context
509+
);
510+
},
511+
exit: (context) => {
512+
console.log(
513+
"Exited repositionstates repositionIdle",
514+
repositionIdle
515+
);
516+
},
517+
},
518+
[repositionActive]: {
519+
entry: (context) => {
520+
console.log(
521+
"Entered repositionstates repositionActive",
522+
context
523+
);
524+
},
525+
exit: (context) => {
526+
console.log(
527+
"Exited repositionstates repositionActive",
528+
repositionIdle
529+
);
530+
},
531+
},
532+
},
533+
},
446534
},
447535
},
448536
},
@@ -460,6 +548,12 @@ export function createCanvasMachine(id: string) {
460548
initial: drag_in_progress_idle,
461549
states: {
462550
[drag_in_progress_idle]: {
551+
entry: (context) => {
552+
console.log("Entered drag_in_progress_idle State", context);
553+
},
554+
exit: (context) => {
555+
console.log("Exited drag_in_progress_idle State", context);
556+
},
463557
on: {
464558
[DRAG_STOPPED]: { target: `#${id}.${ready}` },
465559
[INSIDE_CANVAS]: {
@@ -469,6 +563,12 @@ export function createCanvasMachine(id: string) {
469563
},
470564
},
471565
[drag_in_progress_active]: {
566+
entry: (context) => {
567+
console.log("Entered drag_in_progress_active State", context);
568+
},
569+
exit: (context) => {
570+
console.log("Exited drag_in_progress_active State", context);
571+
},
472572
on: {
473573
[MOUSE_MOVE]: {
474574
actions: ["setMousePosition", "emitMoveWhileDrag"],

0 commit comments

Comments
 (0)