mirror of
https://github.com/suitenumerique/meet.git
synced 2026-09-01 13:17:59 +00:00
fixup! ✨(frontend) add useScreenShareZoom hook for zoom and pan state management
This commit is contained in:
@@ -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(
|
||||||
|
|||||||
Reference in New Issue
Block a user