Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(deck): keep the dock's icons in place — a hill of sizes, no shuffle

Haraldc2f6f893f82b
diff --git a/jarvis/ui/web/frontend/src/components/deck/DeckDock.tsx b/jarvis/ui/web/frontend/src/components/deck/DeckDock.tsx
index 27beaf6c63..eef24e4e76 100644
--- a/jarvis/ui/web/frontend/src/components/deck/DeckDock.tsx
+++ b/jarvis/ui/web/frontend/src/components/deck/DeckDock.tsx
@@ -17,7 +17,6 @@ import {
DOCK_RADIUS_UNITS,
dockSlotAt,
layoutDock,
- maxAnchorLift,
type DockLayout,
} from "@/lib/dockMagnify";
import { playDockTick } from "@/lib/sound";
@@ -40,22 +39,26 @@ import { useT } from "@/i18n";
* a plugin that needs a reconnect lights Plugins.
*
* How the motion is built — the same recipe as the well-known Framer Motion
- * docks, tuned to how the desktop docks actually behave:
+ * docks, with one deliberate difference:
*
+ * - The column is RIGID. No icon ever leaves its place: the hill is a hill of
+ * sizes only, each icon growing around its own rest centre, neighbours a
+ * little, the hovered one most. The desktop docks push neighbours apart to
+ * make room; the maintainer found that shuffle distracting, so it is gone.
+ * Boxes may overlap by a few px at the peak — only the hovered box paints a
+ * surface, and it is drawn on top, so nothing shows.
* - Nothing about the pointer goes through React state. The pointer writes a
* motion value; the whole layout is ONE derived motion value; every icon
* binds its box to that. Re-rendering twenty-odd buttons on every mouse
* event, and then letting a CSS transition chase the result, is what made
* the first version stutter and trail the mouse.
- * - The hill follows the pointer instantly, like the real thing; only its
- * HEIGHT is sprung. Enter the rail and the hill rises in place under the
- * pointer; leave it and it settles back where it was — no pop on entry,
- * no jump on exit, and no lag while inside.
- * - Geometry (the hill, the push-apart, the anchoring that keeps the icon
- * under the pointer under the pointer) is pure math in `lib/dockMagnify.ts`.
- * - Exactly one label: the hovered icon's, sliding along the rail with it and
- * fading in and out. Three labels at once, popping in and out on a size
- * threshold, read as noise.
+ * - The hill follows the pointer instantly; only its HEIGHT is sprung. Enter
+ * the rail and the hill rises in place under the pointer; leave it and it
+ * settles back where it was — no pop on entry, no jump on exit, no lag.
+ * - Geometry is pure math in `lib/dockMagnify.ts`.
+ * - Exactly one label: the hovered icon's, gliding from icon to icon at a
+ * fixed distance from the rail, fading in and out. Three labels at once,
+ * popping in and out on a size threshold, read as noise.
* - A soft detent tick each time the pointer crosses onto another icon, and a
* firmer one on the pick — the ratchet of a picker wheel, quiet.
*
@@ -66,18 +69,20 @@ const GAP = 8; // px — between icon boxes at rest
const ICON = 16; // px — glyph at rest; scales with the box
const RAIL_WIDTH = 64; // px — Tailwind w-16, the column the icons centre in
/**
- * Space above the first icon at rest. Also the headroom the anchoring lifts
- * the row into while magnified — computed from the geometry so a change to
- * the hill can never quietly leave the anchoring clipped.
+ * Space above the first and below the last icon at rest. Also what a
+ * magnified end icon grows into — half its extra size, well under 12 px.
*/
-const PAD_TOP = Math.max(12, maxAnchorLift(BASE, GAP));
+const PAD_TOP = 12;
const PAD_BOTTOM = 12;
/** The rest geometry, for tests that need to aim a pointer at an icon. */
export const DECK_DOCK_GEOMETRY = { BASE, GAP, PAD_TOP } as const;
/** Enter/leave: quick, a hair under critical damping so it never wobbles. */
const HILL_SPRING = { stiffness: 600, damping: 45, mass: 1 };
-/** How far the label sits from the icon's edge. */
-const LABEL_GAP = 12;
+/**
+ * Where the label's left edge sits: a fixed distance beyond the fully grown
+ * icon, so it does not creep sideways while the icon grows under it.
+ */
+const LABEL_LEFT = RAIL_WIDTH / 2 + (BASE * DOCK_MAX_SCALE) / 2 + 12;
/**
* The label glides from icon to icon instead of hopping — critically damped,
* so it settles in ~40 ms and never overshoots the icon it names.
@@ -140,35 +145,28 @@ export function DeckDock({ className }: { className?: string }) {
amount > 0.002 ? y : null,
1 + (DOCK_MAX_SCALE - 1) * amount,
DOCK_RADIUS_UNITS,
- PAD_TOP,
),
hovered: h,
};
});
- const blockHeight = useTransform(frame, (f) => PAD_TOP + f.layout.extent + PAD_BOTTOM);
+ // Rest geometry — positions never move, so this is a plain number.
+ const rest = useMemo(() => layoutDock(items.length, BASE, GAP, null), [items.length]);
+ const blockHeight = PAD_TOP + rest.extent + PAD_BOTTOM;
// --- the one label ------------------------------------------------------
// The last position is kept so the label fades out where it was rather than
- // jumping to a default the instant the pointer leaves.
- const lastLabelPos = useRef({
- top: PAD_TOP + GAP + BASE / 2,
- left: RAIL_WIDTH / 2 + BASE / 2 + LABEL_GAP,
- });
+ // jumping to a default the instant the pointer leaves. Derived from `frame`
+ // (rather than from the hovered index alone) so a scroll under a still
+ // pointer, which re-aims the hill, moves the label along.
+ const lastLabelTop = useRef(PAD_TOP + GAP + BASE / 2);
const labelTopRaw = useTransform(frame, (f) => {
- if (f.hovered < 0) return lastLabelPos.current.top;
- const it = f.layout.items[f.hovered];
- const top = PAD_TOP + it.center - (scrollerRef.current?.scrollTop ?? 0);
- lastLabelPos.current.top = top;
+ if (f.hovered < 0) return lastLabelTop.current;
+ const top = PAD_TOP + f.layout.items[f.hovered].center - (scrollerRef.current?.scrollTop ?? 0);
+ lastLabelTop.current = top;
return top;
});
const labelTopSmooth = useSpring(labelTopRaw, LABEL_SPRING);
const labelTop = reduced ? labelTopRaw : labelTopSmooth;
- const labelLeft = useTransform(frame, (f) => {
- if (f.hovered < 0) return lastLabelPos.current.left;
- const left = RAIL_WIDTH / 2 + f.layout.items[f.hovered].size / 2 + LABEL_GAP;
- lastLabelPos.current.left = left;
- return left;
- });
const setHoveredSlot = useCallback(
(slot: number, tick: boolean) => {
@@ -180,15 +178,14 @@ export function DeckDock({ className }: { className?: string }) {
if (prev < 0 && slot >= 0) {
// A fresh label appears AT its icon; only a label that is already on
// screen glides. Without this it would fly in from wherever the last
- // one faded out. Derived values update on the next frame, so the rest
- // centre is used — the glide closes the last few px itself.
+ // one faded out.
labelTopSmooth.jump(
- PAD_TOP + GAP + slot * (BASE + GAP) + BASE / 2 - (scrollerRef.current?.scrollTop ?? 0),
+ PAD_TOP + rest.items[slot].center - (scrollerRef.current?.scrollTop ?? 0),
);
}
if (tick && slot >= 0) playDockTick("hover");
},
- [hoveredMV, labelTopSmooth],
+ [hoveredMV, labelTopSmooth, rest],
);
const track = useCallback(
@@ -245,13 +242,13 @@ export function DeckDock({ className }: { className?: string }) {
onScroll={onScroll}
className="deck-dock-scroller relative h-full w-full overflow-y-auto overflow-x-hidden"
>
- {/* Height follows the magnified extent so the row never clips. */}
- <motion.div className="relative w-full" style={{ height: blockHeight }}>
+ <div className="relative w-full" style={{ height: blockHeight }}>
{items.map((item, i) => (
<DockIcon
key={item.id}
item={item}
index={i}
+ restCenter={rest.items[i].center}
frame={frame}
label={resolveNavLabel(t, item)}
active={activeSection === item.id || !!item.matchIds?.includes(activeSection)}
@@ -274,7 +271,7 @@ export function DeckDock({ className }: { className?: string }) {
}}
/>
))}
- </motion.div>
+ </div>
</div>
{/* The label rides beside the hovered icon, outside the scroller so the
@@ -290,7 +287,7 @@ export function DeckDock({ className }: { className?: string }) {
animate={{ opacity: 1, x: 0 }}
exit={{ opacity: 0, x: -4 }}
transition={reduced ? { duration: 0 } : { duration: 0.12, ease: "easeOut" }}
- style={{ top: labelTop, left: labelLeft, y: "-50%" }}
+ style={{ top: labelTop, left: LABEL_LEFT, y: "-50%" }}
className="pointer-events-none absolute whitespace-nowrap rounded-md border border-border bg-background/95 px-2 py-1 text-xs text-foreground shadow-md backdrop-blur"
>
{resolveNavLabel(t, hoveredItem)}
@@ -307,6 +304,7 @@ export function DeckDock({ className }: { className?: string }) {
function DockIcon({
item,
index,
+ restCenter,
frame,
label,
active,
@@ -320,6 +318,8 @@ function DockIcon({
}: {
item: NavItem;
index: number;
+ /** The icon's fixed centre along the rail, px from the row's start. */
+ restCenter: number;
frame: MotionValue<DockFrame>;
label: string;
active: boolean;
@@ -334,26 +334,21 @@ function DockIcon({
onBlur: () => void;
}) {
// Each icon binds its box to the shared layout — written straight to the
- // element by the motion runtime, never through a React render.
- const top = useTransform(frame, (f) => {
- const it = f.layout.items[index];
- return PAD_TOP + it.center - it.size / 2;
- });
+ // element by the motion runtime, never through a React render. The centre
+ // is fixed; the box grows around it, so `top` moves up exactly as `size`
+ // grows.
+ const top = useTransform(frame, (f) => PAD_TOP + restCenter - f.layout.items[index].size / 2);
const size = useTransform(frame, (f) => f.layout.items[index].size);
const glyph = useTransform(frame, (f) => ICON * f.layout.items[index].scale);
- const ruleTop = useTransform(frame, (f) => {
- const it = f.layout.items[index];
- return PAD_TOP + it.center - it.size / 2 - GAP / 2 - 0.5;
- });
const Icon = item.icon;
return (
<>
{groupBreak && (
- <motion.span
+ <span
aria-hidden
className="absolute left-4 right-4 h-px bg-border"
- style={{ top: ruleTop }}
+ style={{ top: PAD_TOP + restCenter - BASE / 2 - GAP / 2 - 0.5 }}
/>
)}
<motion.button
@@ -367,6 +362,9 @@ function DockIcon({
className={cn(
"absolute left-1/2 flex items-center justify-center rounded-xl border transition-colors duration-150",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",
+ // On top while hovered: at the peak its box overlaps the neighbours'
+ // (transparent) boxes by a few px, and it must win that overlap.
+ hovered && "z-10",
active
? "border-primary/50 bg-primary/15 text-primary"
: hovered
diff --git a/jarvis/ui/web/frontend/src/lib/dockMagnify.test.ts b/jarvis/ui/web/frontend/src/lib/dockMagnify.test.ts
index b764c1036f..bfe603cf4f 100644
--- a/jarvis/ui/web/frontend/src/lib/dockMagnify.test.ts
+++ b/jarvis/ui/web/frontend/src/lib/dockMagnify.test.ts
@@ -5,7 +5,6 @@ import {
dockSlotAt,
layoutDock,
magnifyScale,
- maxAnchorLift,
} from "@/lib/dockMagnify";
describe("magnifyScale", () => {
@@ -32,24 +31,34 @@ describe("layoutDock", () => {
const { items, extent } = layoutDock(4, 32, 8, null);
expect(items.map((i) => i.scale)).toEqual([1, 1, 1, 1]);
expect(items.map((i) => i.center)).toEqual([24, 64, 104, 144]);
+ expect(items.map((i) => i.size)).toEqual([32, 32, 32, 32]);
expect(extent).toBe(4 * 40 + 8);
});
- it("magnifies the icon under the pointer and pushes the rest outward", () => {
+ it("magnifies the icon under the pointer, its neighbours less — and moves nothing", () => {
const rest = layoutDock(5, 32, 8, null);
// Pointer exactly on the centre of the third icon.
const { items, extent } = layoutDock(5, 32, 8, rest.items[2].center);
expect(items[2].scale).toBeCloseTo(DOCK_MAX_SCALE, 6);
+ expect(items[2].size).toBeCloseTo(32 * DOCK_MAX_SCALE, 6);
expect(items[1].scale).toBeGreaterThan(1);
+ expect(items[1].scale).toBeLessThan(items[2].scale);
expect(items[3].scale).toBeCloseTo(items[1].scale, 9);
- // The row grew — nothing overlaps because everything after the big icon
- // moved by exactly the extra room it needs.
- expect(extent).toBeGreaterThan(rest.extent);
- for (let i = 1; i < items.length; i++) {
- const prevEnd = items[i - 1].center + items[i - 1].size / 2;
- const thisStart = items[i].center - items[i].size / 2;
- expect(thisStart).toBeGreaterThanOrEqual(prevEnd + 8 - 1e-9);
+
+ // The column is rigid: every centre is its rest centre, the extent is the
+ // rest extent. Only sizes changed.
+ expect(items.map((i) => i.center)).toEqual(rest.items.map((i) => i.center));
+ expect(extent).toBe(rest.extent);
+ });
+
+ it("grows each icon around its own centre, so a hovered icon stays where it was", () => {
+ const rest = layoutDock(9, 30, 8, null);
+ for (let k = 0; k < 9; k++) {
+ const { items } = layoutDock(9, 30, 8, rest.items[k].center);
+ expect(items[k].center).toBe(rest.items[k].center);
+ expect(items[k].center - items[k].size / 2).toBeLessThan(rest.items[k].center - 15);
+ expect(items[k].center + items[k].size / 2).toBeGreaterThan(rest.items[k].center + 15);
}
});
@@ -59,51 +68,14 @@ describe("layoutDock", () => {
expect(items[11].scale).toBe(1);
expect(items[11].size).toBe(32);
});
-});
-
-describe("layoutDock — pointer anchoring", () => {
- it("does not lift the row without headroom (top-anchored, as before)", () => {
- const rest = layoutDock(9, 30, 8, null);
- const { items, shift } = layoutDock(9, 30, 8, rest.items[4].center);
- expect(shift).toBe(0);
- // Everything after the hill has been pushed DOWN — the icon under the
- // pointer is no longer centred on it.
- expect(items[4].center).toBeGreaterThan(rest.items[4].center + 10);
- });
-
- it("keeps the icon under the pointer under the pointer when it may lift", () => {
- const rest = layoutDock(9, 30, 8, null);
- const p = rest.items[4].center;
- const { items, shift } = layoutDock(9, 30, 8, p, undefined, undefined, 40);
- expect(shift).toBeLessThan(0);
- expect(items[4].center).toBeCloseTo(p, 6);
- // Still no overlap: neighbours moved by exactly the room they need.
- for (let i = 1; i < items.length; i++) {
- const prevEnd = items[i - 1].center + items[i - 1].size / 2;
- const thisStart = items[i].center - items[i].size / 2;
- expect(thisStart).toBeGreaterThanOrEqual(prevEnd + 8 - 1e-9);
- }
- });
-
- it("pins the material point, not just the centre — the icon's edges stay put too", () => {
- const rest = layoutDock(9, 30, 8, null);
- const top = rest.items[4].center - 15;
- const { items } = layoutDock(9, 30, 8, top, undefined, undefined, 40);
- expect(items[4].center - items[4].size / 2).toBeCloseTo(top, 6);
- });
- it("never lifts more than the headroom allows", () => {
- const rest = layoutDock(9, 30, 8, null);
- const { shift, items } = layoutDock(9, 30, 8, rest.items[6].center, undefined, undefined, 5);
- expect(shift).toBeGreaterThanOrEqual(-5);
- expect(items[0].center - items[0].size / 2).toBeGreaterThanOrEqual(8 - 5 - 1e-9);
- });
-
- it("a pointer past the end pins that end, so the last icon grows towards it", () => {
- const rest = layoutDock(5, 30, 8, null);
- const bottom = rest.items[4].center + 15;
- const { items } = layoutDock(5, 30, 8, bottom + 30, undefined, undefined, 40);
- expect(items[4].center + items[4].size / 2).toBeCloseTo(bottom, 6);
+ it("keeps the peak overlap of neighbouring boxes to a few px", () => {
+ // Boxes may touch at the peak (only the hovered one paints a surface), but
+ // a hill so steep that neighbours swallow each other would read as a mess.
+ const rest = layoutDock(7, 30, 8, null);
+ const { items } = layoutDock(7, 30, 8, rest.items[3].center);
+ const overlap = items[3].size / 2 + items[2].size / 2 - (items[3].center - items[2].center);
+ expect(overlap).toBeLessThan(6);
});
});
@@ -122,15 +94,3 @@ describe("dockSlotAt", () => {
expect(dockSlotAt(10, 0, 30, 8)).toBe(-1);
});
});
-
-describe("maxAnchorLift", () => {
- it("is the headroom the anchoring actually needs — no sample lifts further", () => {
- const need = maxAnchorLift(30, 8);
- expect(need).toBeGreaterThan(0);
- const rest = layoutDock(15, 30, 8, null);
- for (let p = rest.items[6].center - 19; p <= rest.items[8].center + 19; p += 1) {
- const { shift } = layoutDock(15, 30, 8, p, undefined, undefined, 1000);
- expect(-shift).toBeLessThanOrEqual(need + 1e-9);
- }
- });
-});
diff --git a/jarvis/ui/web/frontend/src/lib/dockMagnify.ts b/jarvis/ui/web/frontend/src/lib/dockMagnify.ts
index 9683fc51e0..795238da46 100644
--- a/jarvis/ui/web/frontend/src/lib/dockMagnify.ts
+++ b/jarvis/ui/web/frontend/src/lib/dockMagnify.ts
@@ -1,25 +1,23 @@
/**
* The dock's magnification curve — the pure math behind DeckDock.tsx.
*
- * The effect is the one desktop docks made familiar: the icon under the
- * pointer grows, its neighbours grow a little less, and everything else stays
- * put — a smooth hill, not a step. Three things make it feel right rather than
- * jumpy, and all three live here so they can be tested without a DOM:
+ * The effect is a hill of SIZES, not of positions: the icon under the pointer
+ * grows, its neighbours grow a little less, everything else stays at rest —
+ * and no icon ever leaves its place. Each one grows around its own rest
+ * centre. That is a deliberate departure from the desktop docks, which push
+ * neighbours apart to make room: the maintainer wants the column rigid, so
+ * that a hover reads as "this one lights up" and never as "the row shuffles".
+ * Boxes may therefore overlap by a few px at the peak; the dock draws only the
+ * hovered box with a surface, on top, so the overlap is never visible.
+ *
+ * Two things make the hill feel right rather than jumpy, and both live here so
+ * they can be tested without a DOM:
*
* 1. A cosine falloff over a fixed radius. Linear falloff has a visible kink
* where it hits zero; cosine eases into rest.
- * 2. Positions derived from the SCALES, not from the pointer. Each icon's
- * centre is the running sum of the sizes before it, so growing one pushes
- * the rest outward by exactly the space it takes — no overlap, no gap.
- * 3. The row is ANCHORED AT THE POINTER. Summing sizes from the top pushes
- * every magnified icon downward, away from the pointer that is magnifying
- * it — by almost a full icon in the middle of a long dock, which is what
- * made the old dock feel as if the hill lagged behind the mouse. The real
- * desktop docks lift the row so the point under the pointer stays exactly
- * where it is: what grows above the pointer moves up, what grows below
- * moves down. `headroom` is how far the row may be lifted (the space the
- * dock reserves above its first icon at rest); `maxAnchorLift` says how
- * much a given geometry needs.
+ * 2. Scales measured against the REST centres. Positions never move, so the
+ * icon under the pointer in rest space is also the one visibly under it —
+ * a single hit test (`dockSlotAt`) serves both.
*/
/** Largest scale for the icon directly under the pointer. */
@@ -45,32 +43,25 @@ export function magnifyScale(
export interface DockLayoutItem {
scale: number;
- /** Centre along the dock axis, in px from the dock's start (rest gap included). */
+ /** Centre along the dock axis, in px from the dock's start (rest gap included). Never moves. */
center: number;
- /** Rendered size along the axis, in px. */
+ /** Rendered size along the axis, in px — grows around `center`. */
size: number;
}
export interface DockLayout {
items: DockLayoutItem[];
- /** Where the row ends, in px from the dock's start (trailing gap included). */
+ /** Where the row of REST boxes ends, in px from the dock's start (trailing gap included). Constant. */
extent: number;
- /**
- * How far the whole row was lifted to keep the point under the pointer in
- * place: 0 at rest, negative while magnified, never below `-headroom`.
- */
- shift: number;
}
/**
* Lay out `count` icons of `baseSize` px with `gap` px between them, given the
* pointer position along the axis (`pointer`, px from the start; null = at
- * rest). Returns one entry per icon and the total extent.
+ * rest). Returns one entry per icon and the (constant) rest extent.
*
- * Positions come from the scales — every icon starts where the previous one
- * ended — so the row grows to make room instead of overlapping. With a
- * `headroom` > 0 the row is then lifted (by at most that much) so the point of
- * the rest layout under the pointer stays under the pointer.
+ * Centres are the rest centres whatever the pointer does; only `size` and
+ * `scale` respond to it.
*/
export function layoutDock(
count: number,
@@ -79,87 +70,25 @@ export function layoutDock(
pointer: number | null,
maxScale = DOCK_MAX_SCALE,
radiusUnits = DOCK_RADIUS_UNITS,
- headroom = 0,
): DockLayout {
- const items: DockLayoutItem[] = [];
const stride = baseSize + gap;
- // Rest centres are what the pointer is measured against: measuring against
- // the *magnified* centres would make an icon chase the pointer as it grows.
- const restCenters = Array.from({ length: count }, (_, i) => gap + i * stride + baseSize / 2);
-
- let cursor = gap;
+ const items: DockLayoutItem[] = [];
for (let i = 0; i < count; i++) {
+ const center = gap + i * stride + baseSize / 2;
const scale =
- pointer === null
- ? 1
- : magnifyScale((pointer - restCenters[i]) / stride, maxScale, radiusUnits);
- const size = baseSize * scale;
- items.push({ scale, center: cursor + size / 2, size });
- cursor += size + gap;
+ pointer === null ? 1 : magnifyScale((pointer - center) / stride, maxScale, radiusUnits);
+ items.push({ scale, center, size: baseSize * scale });
}
-
- let shift = 0;
- if (pointer !== null && headroom > 0 && count > 0) {
- // The "material point": which slot of the REST layout is under the pointer,
- // and how far into it. A pointer past either end pins that end's edge, so
- // an icon approached from beyond the row grows towards the pointer.
- const rowStart = gap;
- const rowEnd = gap + (count - 1) * stride + baseSize;
- const p = Math.min(rowEnd, Math.max(rowStart, pointer));
- const i = Math.min(count - 1, Math.max(0, Math.floor((p - rowStart) / stride)));
- const within = p - (rowStart + i * stride);
- const it = items[i];
- const magnified =
- within <= baseSize
- ? it.center - it.size / 2 + (within / baseSize) * it.size
- : it.center + it.size / 2 + (within - baseSize); // in the gap below: gaps do not grow
- // Growth only ever pushes material down, so the lift is never positive.
- shift = Math.max(-headroom, Math.min(0, p - magnified));
- if (shift !== 0) {
- for (const item of items) item.center += shift;
- }
- }
- return { items, extent: cursor + shift, shift };
+ return { items, extent: gap + count * stride };
}
/**
* Which icon's slot a rest-space position falls into: the icon's box plus half
* a gap on either side, so there is no dead zone between neighbours. -1 when
* the position is outside the row.
- *
- * Because the layout is anchored at the pointer, the slot under the pointer in
- * REST space is also the icon visibly under it — one hit test serves both.
*/
export function dockSlotAt(pointer: number, count: number, baseSize: number, gap: number): number {
if (!Number.isFinite(pointer) || count <= 0) return -1;
const i = Math.floor((pointer - gap / 2) / (baseSize + gap));
return i >= 0 && i < count ? i : -1;
}
-
-/**
- * The largest lift `layoutDock` will ever ask for with this geometry — the
- * headroom a dock has to reserve above its first icon so the anchoring is
- * never clipped. Found by sampling pointer positions across one stride in
- * the middle of a long row (that is where the hill has the most material
- * above the pointer). Rounded up to whole px.
- */
-export function maxAnchorLift(
- baseSize: number,
- gap: number,
- maxScale = DOCK_MAX_SCALE,
- radiusUnits = DOCK_RADIUS_UNITS,
-): number {
- const stride = baseSize + gap;
- const count = Math.ceil(radiusUnits) * 2 + 3;
- const mid = Math.floor(count / 2);
- const start = gap + mid * stride;
- let worst = 0;
- const steps = 48;
- for (let s = 0; s <= steps; s++) {
- const p = start + (stride * s) / steps;
- // A generous headroom so the sample measures the unclamped lift.
- const { shift } = layoutDock(count, baseSize, gap, p, maxScale, radiusUnits, baseSize * count);
- worst = Math.max(worst, -shift);
- }
- return Math.ceil(worst);
-}