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( const handleWheel = useCallback(
(e: React.WheelEvent<HTMLDivElement>) => { (e: WheelEvent) => {
// Match browser zoom gesture (Ctrl/Cmd + scroll).
if (!e.ctrlKey && !e.metaKey) return if (!e.ctrlKey && !e.metaKey) return
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
const target = e.currentTarget as HTMLElement
const delta = -e.deltaY * WHEEL_ZOOM_SPEED 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) => { setZoomLevel((prev) => {
const next = clampZoom(prev + delta) const next = clampZoom(prev + delta)
@@ -95,12 +101,6 @@ export function useScreenShareZoom() {
return MIN_ZOOM 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) => { setPanOffset((pan) => {
const zoomRatio = next / prev const zoomRatio = next / prev
return clampPan( return clampPan(