feat(stammbaum): centre the tapped person above the bottom sheet (#703)
On a touch viewport (below the md breakpoint, where the bottom sheet overlays the lower part of the canvas), tapping a person now auto-centres them via recentreAbove with a 0.3 height bias, so the highlighted anchor lands in the band above the sheet instead of behind it (AC8). On desktop the side panel is a flex sibling that never covers the tree, so the bias is 0 and selection does not pan. StammbaumTree's recentre effect takes a centreBiasFraction prop and the page drives it from a matchMedia flag. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
type PanZoomState,
|
||||
clampZoom,
|
||||
clampPan,
|
||||
recentreOn,
|
||||
recentreAbove,
|
||||
cornerView,
|
||||
ZOOM_STEP_KB
|
||||
} from '$lib/person/genealogy/panZoom';
|
||||
@@ -35,6 +35,11 @@ interface Props {
|
||||
onPanZoom?: (state: PanZoomState) => void;
|
||||
/** When set to a node id, the canvas recentres on that node (US-PAN-005). */
|
||||
centreOnId?: string | null;
|
||||
/**
|
||||
* Fraction of the viewBox height to lift a recentred node above the centre,
|
||||
* so on a phone the anchor clears the bottom sheet (#703 AC8). 0 centres it.
|
||||
*/
|
||||
centreBiasFraction?: number;
|
||||
/** Fired on the first pointer interaction with the canvas (affordance dismiss). */
|
||||
onActivity?: () => void;
|
||||
/** When true, the initial view is anchored to the tree's top-left corner. */
|
||||
@@ -56,6 +61,7 @@ let {
|
||||
panZoom,
|
||||
onPanZoom = () => {},
|
||||
centreOnId = null,
|
||||
centreBiasFraction = 0,
|
||||
onActivity,
|
||||
anchorTopLeft = false,
|
||||
onSelect,
|
||||
@@ -219,7 +225,7 @@ $effect(() => {
|
||||
if (!id) return;
|
||||
untrack(() => {
|
||||
const c = nodeCenter(id);
|
||||
if (c) onPanZoom(recentreOn(c, baseCentre, panZoom, true));
|
||||
if (c) onPanZoom(recentreAbove(c, baseCentre, panZoom, baseDims.h, centreBiasFraction));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user