mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
b61c168430
Add OverlayScrollArea with shared thumb metrics and drag handling; size the thumb against the rail track height so panel insets cannot push it past the visible rail. Route scroll uses a stable viewport id; Genres restores scroll and infinite-scroll observation against that viewport (merged with upstream virtualized genres list and lazy routes behind Suspense). Suppress queue resizer activation when the pointer targets the main-route overlay scrollbar; disable the resizer while dragging the thumb and use a grabbing cursor on the body. Apply WebKitGTK smooth wheel to the mini webview as well as main; the mini window reapplies the persisted setting after auth store hydration.
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
export type OverlayScrollbarThumbMeta = {
|
||
thumbH: number;
|
||
thumbT: number;
|
||
visible: boolean;
|
||
};
|
||
|
||
/**
|
||
* @param trackHeight — pixel height of the overlay rail (inset top/bottom).
|
||
* When shorter than the viewport, thumb size/position must use this or the
|
||
* thumb’s bottom extends past the visible rail at max scroll.
|
||
*/
|
||
export function computeOverlayScrollbarThumbMeta(
|
||
el: HTMLElement | null,
|
||
trackHeight?: number,
|
||
): OverlayScrollbarThumbMeta {
|
||
if (!el) return { thumbH: 0, thumbT: 0, visible: false };
|
||
const { scrollTop, scrollHeight, clientHeight } = el;
|
||
if (scrollHeight <= clientHeight + 1) {
|
||
return { thumbH: 0, thumbT: 0, visible: false };
|
||
}
|
||
const th =
|
||
trackHeight != null && trackHeight > 0 ? Math.min(trackHeight, clientHeight) : clientHeight;
|
||
const ratio = clientHeight / scrollHeight;
|
||
const rawH = Math.round(ratio * th);
|
||
const thumbH = Math.min(th, Math.max(24, rawH));
|
||
const range = Math.max(0, th - thumbH);
|
||
const scrollRange = scrollHeight - clientHeight;
|
||
const thumbT =
|
||
scrollRange > 0
|
||
? Math.min(range, Math.max(0, Math.round((scrollTop / scrollRange) * range)))
|
||
: 0;
|
||
return { thumbH, thumbT, visible: true };
|
||
}
|