* fix(app): preserve loader behavior in retained panels Keep the running footer mounted across panel switches. Inactive loaders stop their animation work, then realign to the original wall-clock phase before they become visible. * perf(app): remove inactive loader wrapper worklet * perf(app): pause hidden turn elapsed timers * perf(app): reduce loader animation work Keep one wall-clock-aligned clock for visible loaders and detach retained hidden loaders without unmounting them. Preserve the 950 ms sequence and reduced-motion behavior.
23 lines
691 B
TypeScript
23 lines
691 B
TypeScript
const SYNCED_LOADER_DURATION_MS = 950;
|
|
export const SYNCED_LOADER_DOT_COUNT = 6;
|
|
|
|
const SYNCED_LOADER_OPACITY_STATES = [
|
|
[1, 0, 0.78, 0, 0.56, 0.34],
|
|
[0.78, 1, 0.56, 0, 0.34, 0],
|
|
[0.56, 0.78, 0.34, 1, 0, 0],
|
|
[0.34, 0.56, 0, 0.78, 0, 1],
|
|
[0, 0.34, 0, 0.56, 1, 0.78],
|
|
[0, 0, 1, 0.34, 0.78, 0.56],
|
|
] as const;
|
|
|
|
export function getSyncedLoaderStep(nowMs: number): number {
|
|
"worklet";
|
|
const elapsedMs = nowMs % SYNCED_LOADER_DURATION_MS;
|
|
return Math.floor((elapsedMs * SYNCED_LOADER_DOT_COUNT) / SYNCED_LOADER_DURATION_MS);
|
|
}
|
|
|
|
export function getSyncedLoaderDotOpacity(step: number, dot: number): number {
|
|
"worklet";
|
|
return SYNCED_LOADER_OPACITY_STATES[step]?.[dot] ?? 0;
|
|
}
|