fix: anchor board zoom to pointer

This commit is contained in:
2026-08-14 16:44:43 +02:00
parent f97dceb4fe
commit a4b22a574b
4 changed files with 34 additions and 4 deletions
+10
View File
@@ -16,6 +16,7 @@ import {
timelineRange,
zoomFromWheel,
zoomFromPinch,
zoomViewportAt,
} from './boardDomain'
describe('red thread geometry', () => {
@@ -80,6 +81,15 @@ describe('board coordinate math', () => {
expect(zoomFromPinch(1, 0, 120)).toBe(1)
})
it('keeps the board point beneath the cursor fixed while zooming', () => {
const anchor = { x: 110, y: 120 }
const zoomed = zoomViewportAt(state.viewport, 1, anchor)
expect(zoomed).toEqual({ x: -90, y: -80, zoom: 1 })
expect(zoomed.x + 200 * zoomed.zoom).toBe(anchor.x)
expect(zoomed.y + 200 * zoomed.zoom).toBe(anchor.y)
expect(zoomViewportAt(zoomed, .5, anchor)).toEqual(state.viewport)
})
it('places new exhibits in deterministic open slots', () => {
const preferred = { x: 500, y: 400 }
expect(nextOpenBoardPosition([], preferred, { width: 280 })).toEqual(preferred)