From 9b8d7cb66d7379574d07a4a754dced79b6573c0f Mon Sep 17 00:00:00 2001 From: Ovgodd Date: Wed, 9 Sep 2026 10:37:07 +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/hooks/useScreenShareZoom.ts | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/src/frontend/src/features/rooms/livekit/hooks/useScreenShareZoom.ts b/src/frontend/src/features/rooms/livekit/hooks/useScreenShareZoom.ts index 9fb5ccb3..4b65ea83 100644 --- a/src/frontend/src/features/rooms/livekit/hooks/useScreenShareZoom.ts +++ b/src/frontend/src/features/rooms/livekit/hooks/useScreenShareZoom.ts @@ -100,34 +100,31 @@ export const useScreenShareZoom = () => { ) }, []) - const zoomIn = useCallback(() => { - const next = clampZoom(zoomRef.current + ZOOM_STEP) - zoomRef.current = next - panRef.current = clampPan(panRef.current, next, readPictureRatio()) - applyTransform() - applyCursor() - flush() - }, [applyTransform, applyCursor, flush, readPictureRatio]) + const setZoom = useCallback( + (next: number) => { + zoomRef.current = next + panRef.current = + next <= MIN_ZOOM + ? { x: 0, y: 0 } + : clampPan(panRef.current, next, readPictureRatio()) + applyTransform() + applyCursor() + flush() + }, + [applyTransform, applyCursor, flush, readPictureRatio] + ) - const zoomOut = useCallback(() => { - const next = clampZoom(zoomRef.current - ZOOM_STEP) - zoomRef.current = next - panRef.current = - next <= MIN_ZOOM - ? { x: 0, y: 0 } - : clampPan(panRef.current, next, readPictureRatio()) - applyTransform() - applyCursor() - flush() - }, [applyTransform, applyCursor, flush, readPictureRatio]) + const zoomIn = useCallback( + () => setZoom(clampZoom(zoomRef.current + ZOOM_STEP)), + [setZoom] + ) - const resetZoom = useCallback(() => { - zoomRef.current = MIN_ZOOM - panRef.current = { x: 0, y: 0 } - applyTransform() - applyCursor() - flush() - }, [applyTransform, applyCursor, flush]) + const zoomOut = useCallback( + () => setZoom(clampZoom(zoomRef.current - ZOOM_STEP)), + [setZoom] + ) + + const resetZoom = useCallback(() => setZoom(MIN_ZOOM), [setZoom]) // Must be attached with { passive: false } so preventDefault() blocks // the browser's native Ctrl+scroll page zoom.