@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 16 lines 551 Bytes
Raw
1 export interface FabScrollState {
2 readonly anchor: number;
3 readonly expanded: boolean;
4 }
5
6 export function updateFabScroll(
7 state: FabScrollState,
8 offset: number,
9 maxOffset: number,
10 ): FabScrollState {
11 const y = Math.max(0, Math.min(offset, Math.max(0, maxOffset)));
12 if (y <= 8) return { anchor: y, expanded: true };
13 const anchor = state.expanded ? Math.min(state.anchor, y) : Math.max(state.anchor, y);
14 if (Math.abs(y - anchor) >= 12) return { anchor: y, expanded: !state.expanded };
15 return { anchor, expanded: state.expanded };
16 }