fix: anchor board zoom to pointer
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user