mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-30 20:14:01 +01:00
Yaak Proxy: scale resized numeric column widths with the interface size too
Every numeric width is kept in pixels at the default interface size, so the least width matches what renders at any size and a resize follows the pointer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
82ac6e5c15
commit
7057a902c7
3 files changed
+57
-55
No files matched your search
@@ -46,6 +46,7 @@ import {
|
||||
resetWidth,
|
||||
resetWidths,
|
||||
resizeColumn,
|
||||
resizeDistance,
|
||||
toggleColumn,
|
||||
unavailableColumns,
|
||||
} from "../lib/columns";
|
||||
@@ -262,9 +263,12 @@ export const FlowListHeader = memo(function FlowListHeader({
|
||||
sort={sort}
|
||||
onSort={onSort}
|
||||
onResizeStart={() => {
|
||||
startWidth.current = shownWidth(gridRef.current, c);
|
||||
startWidth.current = c.current;
|
||||
}}
|
||||
onResizeMove={(dx) => {
|
||||
const by = resizeDistance(c, dx, rootFontSize());
|
||||
setPrefs((p) => resizeColumn(p, c.id, startWidth.current + by));
|
||||
}}
|
||||
onResizeMove={(dx) => setPrefs((p) => resizeColumn(p, c.id, startWidth.current + dx))}
|
||||
onResetWidth={() => setPrefs((p) => resetWidth(p, c.id))}
|
||||
/>
|
||||
))}
|
||||
@@ -279,18 +283,9 @@ export const FlowListHeader = memo(function FlowListHeader({
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* A column's content width as laid out, so a resize starts from what shows: a numeric column's
|
||||
* can be wider than its width in pixels, at its default or its least width, at a larger
|
||||
* interface size
|
||||
*/
|
||||
function shownWidth(grid: HTMLElement | null, c: Column): number {
|
||||
if (c.fitChars == null) return c.current;
|
||||
const cell = grid?.querySelector<HTMLElement>(`[data-column="${c.id}"]`);
|
||||
if (cell == null) return c.current;
|
||||
const style = getComputedStyle(cell);
|
||||
const padding = Number.parseFloat(style.paddingLeft) + Number.parseFloat(style.paddingRight);
|
||||
return cell.getBoundingClientRect().width - padding;
|
||||
/** The interface font size now, which numeric columns' widths grow with */
|
||||
function rootFontSize(): number {
|
||||
return Number.parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||
}
|
||||
|
||||
interface HeaderCellProps {
|
||||
|
||||
Reference in new issue
Block a user