MCPcopy
hub / github.com/anomalyco/opencode / createSizing

Function createSizing

packages/app/src/pages/session/helpers.ts:158–196  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

156}
157
158export const createSizing = () => {
159 const [state, setState] = createStore({ active: false })
160 let t: number | undefined
161
162 const stop = () => {
163 if (t !== undefined) {
164 clearTimeout(t)
165 t = undefined
166 }
167 setState("active", false)
168 }
169
170 const start = () => {
171 if (t !== undefined) {
172 clearTimeout(t)
173 t = undefined
174 }
175 setState("active", true)
176 }
177
178 onMount(() => {
179 makeEventListener(window, "pointerup", stop)
180 makeEventListener(window, "pointercancel", stop)
181 makeEventListener(window, "blur", stop)
182 })
183
184 onCleanup(() => {
185 if (t !== undefined) clearTimeout(t)
186 })
187
188 return {
189 active: () => state.active,
190 start,
191 touch() {
192 start()
193 t = window.setTimeout(stop, 120)
194 },
195 }
196}
197
198export type Sizing = ReturnType<typeof createSizing>

Callers 2

PageFunction · 0.90
TerminalPanelFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected