feat(stammbaum): mobile read path — pan, zoom, fit-to-view (#692) #694

Merged
marcel merged 39 commits from feat/issue-692-stammbaum-mobile-panzoom into main 2026-05-30 07:43:44 +02:00
2 changed files with 11 additions and 5 deletions
Showing only changes of commit ecae789be2 - Show all commits

View File

@@ -54,10 +54,12 @@ describe('StammbaumTree viewBox', () => {
expect(w).toBe(1200);
expect(h).toBe(800);
// …but the origin is shifted by the pan offset.
const unpannedX = -(1200 / 2 - 160 / 2); // single 160-wide node centred
expect(x).toBeCloseTo(unpannedX + 100, 6);
expect(y).toBeCloseTo(-(800 / 2 - 56 / 2) + 40, 6);
// …but the viewBox centre is the content centroid shifted by the pan
// offset (at pan {0,0} the centre sits on the centroid — see the test
// below). This avoids hard-coding the layout's absolute coordinates.
const c = rectsCentroid(svg);
expect(x + w / 2 - c.x).toBeCloseTo(100, 6);
expect(y + h / 2 - c.y).toBeCloseTo(40, 6);
});
it('uses the minimum size and centers a single node', async () => {

View File

@@ -17,7 +17,11 @@ vi.mock('$app/state', () => ({
const replaceState = vi.fn();
vi.mock('$app/navigation', () => ({
replaceState: (...args: unknown[]) => replaceState(...args)
replaceState: (...args: unknown[]) => replaceState(...args),
// StammbaumSidePanel (rendered transitively) imports invalidateAll/goto, so
// the mock must provide every export the module graph uses.
invalidateAll: vi.fn(),
goto: vi.fn()
}));
afterEach(cleanup);