fixup! (frontend) add useScreenShareZoom hook for zoom and pan state management

This commit is contained in:
Cyril
2026-07-13 16:00:01 +02:00
parent 66221eb17f
commit e3dd317c8a
@@ -79,14 +79,20 @@ export function useScreenShareZoom() {
)
const handleWheel = useCallback(
(e: React.WheelEvent<HTMLDivElement>) => {
// Match browser zoom gesture (Ctrl/Cmd + scroll).
(e: WheelEvent) => {
if (!e.ctrlKey && !e.metaKey) return
e.preventDefault()
e.stopPropagation()
const target = e.currentTarget as HTMLElement
const delta = -e.deltaY * WHEEL_ZOOM_SPEED
const rect = target.getBoundingClientRect()
const cursorXPercent =
((e.clientX - rect.left) / rect.width) * 100 - PAN_CLAMP_HALF
const cursorYPercent =
((e.clientY - rect.top) / rect.height) * 100 - PAN_CLAMP_HALF
setZoomLevel((prev) => {
const next = clampZoom(prev + delta)
@@ -95,12 +101,6 @@ export function useScreenShareZoom() {
return MIN_ZOOM
}
const rect = e.currentTarget.getBoundingClientRect()
const cursorXPercent =
((e.clientX - rect.left) / rect.width) * 100 - PAN_CLAMP_HALF
const cursorYPercent =
((e.clientY - rect.top) / rect.height) * 100 - PAN_CLAMP_HALF
setPanOffset((pan) => {
const zoomRatio = next / prev
return clampPan(