Open History to see the last commit
1export interface FabScrollState {
2 readonly anchor: number;
3 readonly expanded: boolean;
4}
5
6export 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}