mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:20:33 +08:00
Ship folder-based workspaces and data migration, daily practice, redesigned provider and model settings, and streaming conversation improvements. Synchronize README translations and document the archive/permanent-delete upgrade behavior in assets/releases/ver1-6-9.md. Reduce initial JavaScript by deduplicating English resources and loading animation features after hydration. Keep the existing route size budgets. Update regression fixtures and browser audits for scoped URLs and the new settings and learning interfaces.
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
/**
|
|
* Tiny module-level handoff for "expand from the clicked element" picker
|
|
* animations.
|
|
*
|
|
* When a menu row that opens a fullscreen picker is clicked, the trigger
|
|
* records its on-screen rect here. `PickerShell` reads it on open and animates
|
|
* the modal card *outward from that rect* — so the picker feels like it grows
|
|
* out of the row the user tapped, rather than popping in at screen center.
|
|
*
|
|
* The value is freshness-gated rather than consumed/cleared: a `peek` is
|
|
* idempotent (safe under React's double-render in dev) and a stale origin
|
|
* (e.g. a picker opened from somewhere other than the menu) simply falls back
|
|
* to the default centered animation.
|
|
*/
|
|
|
|
interface PickerOrigin {
|
|
rect: DOMRect;
|
|
ts: number;
|
|
}
|
|
|
|
let current: PickerOrigin | null = null;
|
|
|
|
export function setPickerOrigin(rect: DOMRect): void {
|
|
current = { rect, ts: Date.now() };
|
|
}
|
|
|
|
/**
|
|
* Return the last trigger rect if it was set within `maxAgeMs` (the click →
|
|
* open hop happens in the same tick, so the window is generous). Idempotent.
|
|
*/
|
|
export function peekPickerOrigin(maxAgeMs = 700): DOMRect | null {
|
|
if (!current) return null;
|
|
if (Date.now() - current.ts > maxAgeMs) return null;
|
|
return current.rect;
|
|
}
|
|
|
|
/** Map the final surface back onto the actual trigger, including off-center layouts. */
|
|
export function pickerFlight(
|
|
source: Pick<DOMRect, "x" | "y" | "width" | "height">,
|
|
target: Pick<DOMRect, "x" | "y" | "width" | "height">,
|
|
) {
|
|
return {
|
|
x: source.x + source.width / 2 - target.x - target.width / 2,
|
|
y: source.y + source.height / 2 - target.y - target.height / 2,
|
|
scaleX: target.width > 0 ? source.width / target.width : 1,
|
|
scaleY: target.height > 0 ? source.height / target.height : 1,
|
|
};
|
|
}
|