From 0b02f6579e4d0ce443f844f43fa718ac74bd77c5 Mon Sep 17 00:00:00 2001 From: Ovgodd Date: Tue, 1 Sep 2026 09:07:10 +0200 Subject: [PATCH] =?UTF-8?q?fixup!=20=E2=99=BB=EF=B8=8F(frontend)=20refacto?= =?UTF-8?q?r=20screen=20share=20zoom=20pan=20with=20useMove=20and=20impera?= =?UTF-8?q?tive=20DOM=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rooms/livekit/utils/screenShareZoom.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/frontend/src/features/rooms/livekit/utils/screenShareZoom.ts b/src/frontend/src/features/rooms/livekit/utils/screenShareZoom.ts index 20fcb09e..51912642 100644 --- a/src/frontend/src/features/rooms/livekit/utils/screenShareZoom.ts +++ b/src/frontend/src/features/rooms/livekit/utils/screenShareZoom.ts @@ -2,7 +2,6 @@ export const MIN_ZOOM = 1 export const MAX_ZOOM = 4 export const ZOOM_STEP = 0.1 export const WHEEL_ZOOM_SPEED = 0.002 -export const WHEEL_ZOOM_FOCUS_BLEND = 0.3 export const PAN_STEP = 5 export const PAN_CLAMP_HALF = 50 @@ -59,7 +58,10 @@ export const getCursorFromZoomState = (zoom: number, dragging: boolean) => { return dragging ? 'grabbing' : 'grab' } -// Blend the current pan toward the cursor position so the zoom "tracks" the pointer. +// Keep the content point under the cursor anchored while zooming. With +// `scale(z) translate(pan%)`, a point at `offset` from the center renders at +// `z * (offset + pan)`, so holding it still gives: +// pan' = pan + cursor * (1 / zoom' - 1 / zoom). export const getWheelPanOffset = ({ pan, prevZoom, @@ -73,15 +75,11 @@ export const getWheelPanOffset = ({ cursorXPercent: number cursorYPercent: number }): PanOffset => { - const zoomRatio = nextZoom / prevZoom + const panShift = 1 / nextZoom - 1 / prevZoom return clampPan( { - x: - pan.x + - (cursorXPercent - pan.x) * (1 - 1 / zoomRatio) * WHEEL_ZOOM_FOCUS_BLEND, - y: - pan.y + - (cursorYPercent - pan.y) * (1 - 1 / zoomRatio) * WHEEL_ZOOM_FOCUS_BLEND, + x: pan.x + cursorXPercent * panShift, + y: pan.y + cursorYPercent * panShift, }, nextZoom )