(name: PatchyIdleActionName)
| 120 | timers.add(id); |
| 121 | }; |
| 122 | const play = (name: PatchyIdleActionName) => { |
| 123 | if (document.hidden) { |
| 124 | return; |
| 125 | } |
| 126 | const action: PatchyIdleAction = patchyIdleActions[name]; |
| 127 | isBusy = true; |
| 128 | keyRef.current += 1; |
| 129 | setState({ |
| 130 | face: action.face, |
| 131 | // Animated faces bring their own motion. |
| 132 | motion: |
| 133 | prefersReducedMotion || isPatchyFaceAnimated(action.face) |
| 134 | ? null |
| 135 | : (action.motion ?? null), |
| 136 | key: keyRef.current, |
| 137 | }); |
| 138 | later(() => { |
| 139 | isBusy = false; |
| 140 | setState((current) => ({ ...current, face: null, motion: null })); |
| 141 | }, action.ms); |
| 142 | }; |
| 143 | const blinkLoop = () => { |
| 144 | later(() => { |
| 145 | if (!isBusy) { |
no test coverage detected