Files
psysonic/src/utils/overlayScrollbarMetrics.ts
T
cucadmuh b61c168430 fix(ui): overlay scrollbars, resizer hit-test, and Linux mini wheel (#255)
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.
2026-04-21 22:44:28 +02:00

34 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
* thumbs 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 };
}