MCPcopy Create free account
hub / github.com/TodePond/ScreenPond / fireHandEvent

Function fireHandEvent

source/hand.js:66–89  ·  view source on GitHub ↗
(context, hand, eventName, args = {})

Source from the content-addressed store, hash-verified

64
65const HAND_STATE = {};
66export const fireHandEvent = (context, hand, eventName, args = {}) => {
67 let oldState = hand.state;
68 let newState = hand.state;
69
70 // Keep firing state's events until the state stops changing
71 do {
72 oldState = newState;
73 const event = oldState[eventName];
74 if (event === undefined) break;
75 newState = event({ context, hand, ...args });
76 } while (oldState !== newState);
77
78 // Update cursor if we need to
79 if (newState.cursor !== hand.cursor) {
80 context.canvas.style["cursor"] = newState.cursor;
81 hand.cursor = newState.cursor;
82 }
83
84 if (hand.hidden) {
85 context.canvas.style["cursor"] = "crosshair";
86 }
87
88 hand.state = newState;
89};
90
91export const registerRightClick = () => {
92 on.contextmenu((e) => e.preventDefault(), { passive: false });

Callers 1

main.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected