@embedpdf/plugin-zoom 2.0.0-next.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/preact/adapter.d.ts +1 -1
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +217 -71
- package/dist/preact/index.js.map +1 -1
- package/dist/preact/viewport.d.ts +1 -0
- package/dist/react/adapter.d.ts +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +217 -71
- package/dist/react/index.js.map +1 -1
- package/dist/react/viewport.d.ts +1 -0
- package/dist/shared/components/index.d.ts +1 -1
- package/dist/shared/components/zoom-gesture-wrapper.d.ts +12 -0
- package/dist/shared/hooks/index.d.ts +1 -1
- package/dist/shared/hooks/use-pinch-zoom.d.ts +3 -1
- package/dist/shared/hooks/use-zoom-gesture.d.ts +5 -0
- package/dist/shared/utils/pinch-zoom-logic.d.ts +11 -2
- package/dist/shared/utils/zoom-gesture-logic.d.ts +18 -0
- package/dist/shared-preact/components/index.d.ts +1 -1
- package/dist/shared-preact/components/zoom-gesture-wrapper.d.ts +12 -0
- package/dist/shared-preact/hooks/index.d.ts +1 -1
- package/dist/shared-preact/hooks/use-pinch-zoom.d.ts +3 -1
- package/dist/shared-preact/hooks/use-zoom-gesture.d.ts +5 -0
- package/dist/shared-preact/utils/pinch-zoom-logic.d.ts +11 -2
- package/dist/shared-preact/utils/zoom-gesture-logic.d.ts +18 -0
- package/dist/shared-react/components/index.d.ts +1 -1
- package/dist/shared-react/components/zoom-gesture-wrapper.d.ts +12 -0
- package/dist/shared-react/hooks/index.d.ts +1 -1
- package/dist/shared-react/hooks/use-pinch-zoom.d.ts +3 -1
- package/dist/shared-react/hooks/use-zoom-gesture.d.ts +5 -0
- package/dist/shared-react/utils/pinch-zoom-logic.d.ts +11 -2
- package/dist/shared-react/utils/zoom-gesture-logic.d.ts +18 -0
- package/dist/shared-svelte/utils/zoom-gesture-logic.d.ts +18 -0
- package/dist/shared-vue/utils/zoom-gesture-logic.d.ts +18 -0
- package/dist/svelte/components/ZoomGestureWrapper.svelte.d.ts +14 -0
- package/dist/svelte/components/index.d.ts +1 -1
- package/dist/svelte/hooks/index.d.ts +1 -1
- package/dist/svelte/hooks/use-pinch-zoom.svelte.d.ts +11 -2
- package/dist/svelte/hooks/use-zoom-gesture.svelte.d.ts +16 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +214 -71
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/index.d.ts +1 -1
- package/dist/vue/components/{pinch-wrapper.vue.d.ts → zoom-gesture-wrapper.vue.d.ts} +8 -1
- package/dist/vue/hooks/index.d.ts +1 -1
- package/dist/vue/hooks/use-zoom-gesture.d.ts +17 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +211 -72
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -12
- package/dist/hammer-DhVzwxwy.cjs +0 -7
- package/dist/hammer-DhVzwxwy.cjs.map +0 -1
- package/dist/hammer-e1aXHboh.js +0 -1810
- package/dist/hammer-e1aXHboh.js.map +0 -1
- package/dist/shared/components/pinch-wrapper.d.ts +0 -8
- package/dist/shared-preact/components/pinch-wrapper.d.ts +0 -8
- package/dist/shared-react/components/pinch-wrapper.d.ts +0 -8
- package/dist/shared-svelte/utils/pinch-zoom-logic.d.ts +0 -9
- package/dist/shared-vue/utils/pinch-zoom-logic.d.ts +0 -9
- package/dist/svelte/components/PinchWrapper.svelte.d.ts +0 -10
- package/dist/vue/hooks/use-pinch-zoom.d.ts +0 -8
package/dist/react/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-zoom.ts","../../src/shared/utils/pinch-zoom-logic.ts","../../src/shared/hooks/use-pinch-zoom.ts","../../src/shared/components/marquee-zoom.tsx","../../src/shared/components/pinch-wrapper.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { initialDocumentState, ZoomDocumentState, ZoomPlugin } from '@embedpdf/plugin-zoom';\nimport { useEffect, useState } from '@framework';\n\nexport const useZoomCapability = () => useCapability<ZoomPlugin>(ZoomPlugin.id);\nexport const useZoomPlugin = () => usePlugin<ZoomPlugin>(ZoomPlugin.id);\n\n/**\n * Hook for zoom state for a specific document\n * @param documentId Document ID\n */\nexport const useZoom = (documentId: string) => {\n const { provides } = useZoomCapability();\n const [state, setState] = useState<ZoomDocumentState>(initialDocumentState);\n\n useEffect(() => {\n if (!provides) return;\n\n const scope = provides.forDocument(documentId);\n\n // Get initial state\n setState(scope.getState());\n\n // Subscribe to state changes\n return scope.onStateChange((newState) => {\n setState(newState);\n });\n }, [provides, documentId]);\n\n return {\n state,\n provides: provides?.forDocument(documentId) ?? null,\n };\n};\n","import type { ViewportCapability } from '@embedpdf/plugin-viewport';\nimport type { ZoomCapability } from '@embedpdf/plugin-zoom';\n\nexport interface PinchZoomDeps {\n element: HTMLDivElement;\n documentId: string;\n viewportProvides: ViewportCapability;\n zoomProvides: ZoomCapability;\n}\n\nexport function setupPinchZoom({\n element,\n documentId,\n viewportProvides,\n zoomProvides,\n}: PinchZoomDeps) {\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n let hammer: any | undefined;\n let initialZoom = 0;\n let lastCenter = { x: 0, y: 0 };\n\n const viewportScope = viewportProvides.forDocument(documentId);\n const zoomScope = zoomProvides.forDocument(documentId);\n\n const getState = () => zoomScope.getState();\n\n const updateTransform = (scale: number) => {\n element.style.transform = `scale(${scale})`;\n };\n\n const resetTransform = () => {\n element.style.transform = 'none';\n element.style.transformOrigin = '0 0';\n };\n\n const pinchStart = (e: HammerInput) => {\n initialZoom = getState().currentZoomLevel;\n\n const contRect = viewportScope.getBoundingRect();\n\n lastCenter = {\n x: e.center.x - contRect.origin.x,\n y: e.center.y - contRect.origin.y,\n };\n\n const innerRect = element.getBoundingClientRect();\n element.style.transformOrigin = `${e.center.x - innerRect.left}px ${e.center.y - innerRect.top}px`;\n\n if (e.srcEvent?.cancelable) {\n e.srcEvent.preventDefault();\n e.srcEvent.stopPropagation();\n }\n };\n\n const pinchMove = (e: HammerInput) => {\n updateTransform(e.scale);\n if (e.srcEvent?.cancelable) {\n e.srcEvent.preventDefault();\n e.srcEvent.stopPropagation();\n }\n };\n\n const pinchEnd = (e: HammerInput) => {\n const delta = (e.scale - 1) * initialZoom;\n zoomScope.requestZoomBy(delta, { vx: lastCenter.x, vy: lastCenter.y });\n\n resetTransform();\n initialZoom = 0;\n };\n\n const setupHammer = async () => {\n try {\n const Hammer = (await import('hammerjs')).default;\n\n const inputClass = (() => {\n const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;\n const SUPPORT_TOUCH = 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n const SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);\n if (SUPPORT_ONLY_TOUCH) return Hammer.TouchInput;\n if (!SUPPORT_TOUCH) return Hammer.MouseInput;\n return Hammer.TouchMouseInput;\n })();\n\n hammer = new Hammer(element, {\n touchAction: 'pan-x pan-y',\n inputClass,\n });\n\n hammer.get('pinch').set({ enable: true, pointers: 2, threshold: 0.1 });\n\n hammer.on('pinchstart', pinchStart);\n hammer.on('pinchmove', pinchMove);\n hammer.on('pinchend', pinchEnd);\n } catch (error) {\n console.warn('Failed to load HammerJS:', error);\n }\n };\n\n setupHammer();\n\n return () => {\n hammer?.destroy();\n resetTransform();\n };\n}\n","import { useEffect, useRef } from '@framework';\nimport { useCapability } from '@embedpdf/core/@framework';\nimport { ViewportPlugin } from '@embedpdf/plugin-viewport';\nimport { setupPinchZoom } from '../utils/pinch-zoom-logic';\nimport { useZoomCapability } from './use-zoom';\n\nexport function usePinch(documentId: string) {\n const { provides: viewportProvides } = useCapability<ViewportPlugin>('viewport');\n const { provides: zoomProvides } = useZoomCapability();\n const elementRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const element = elementRef.current;\n if (!element || !viewportProvides || !zoomProvides) {\n return;\n }\n\n return setupPinchZoom({\n element,\n documentId,\n viewportProvides,\n zoomProvides,\n });\n }, [viewportProvides, zoomProvides, documentId]);\n\n return { elementRef };\n}\n","import { useEffect, useMemo, useState } from '@framework';\nimport { Rect } from '@embedpdf/models';\nimport { useZoomCapability } from '../hooks/use-zoom';\nimport { useDocumentState } from '@embedpdf/core/@framework';\n\ninterface MarqueeZoomProps {\n documentId: string;\n pageIndex: number;\n scale?: number;\n className?: string;\n stroke?: string;\n fill?: string;\n}\n\nexport const MarqueeZoom = ({\n documentId,\n pageIndex,\n scale: scaleOverride,\n className,\n stroke = 'rgba(33,150,243,0.8)',\n fill = 'rgba(33,150,243,0.15)',\n}: MarqueeZoomProps) => {\n const { provides: zoomPlugin } = useZoomCapability();\n const documentState = useDocumentState(documentId);\n const [rect, setRect] = useState<Rect | null>(null);\n\n const actualScale = useMemo(() => {\n if (scaleOverride !== undefined) return scaleOverride;\n return documentState?.scale ?? 1;\n }, [scaleOverride, documentState?.scale]);\n\n useEffect(() => {\n if (!zoomPlugin) return;\n return zoomPlugin.registerMarqueeOnPage({\n documentId,\n pageIndex,\n scale: actualScale,\n callback: {\n onPreview: setRect,\n },\n });\n }, [zoomPlugin, documentId, pageIndex, actualScale]);\n\n if (!rect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n pointerEvents: 'none',\n left: rect.origin.x * actualScale,\n top: rect.origin.y * actualScale,\n width: rect.size.width * actualScale,\n height: rect.size.height * actualScale,\n border: `1px solid ${stroke}`,\n background: fill,\n boxSizing: 'border-box',\n }}\n className={className}\n />\n );\n};\n","import { ReactNode, HTMLAttributes, CSSProperties } from '@framework';\nimport { usePinch } from '../hooks';\n\ntype PinchWrapperProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ReactNode;\n documentId: string;\n style?: CSSProperties;\n};\n\nexport function PinchWrapper({ children, documentId, style, ...props }: PinchWrapperProps) {\n const { elementRef } = usePinch(documentId);\n\n return (\n <div\n ref={elementRef}\n {...props}\n style={{\n ...style,\n display: 'block',\n width: 'fit-content',\n overflow: 'visible',\n boxSizing: 'border-box',\n margin: '0px auto',\n }}\n >\n {children}\n </div>\n );\n}\n"],"names":["useZoomCapability","useCapability","ZoomPlugin","id","setupPinchZoom","element","documentId","viewportProvides","zoomProvides","window","hammer","initialZoom","lastCenter","x","y","viewportScope","forDocument","zoomScope","resetTransform","style","transform","transformOrigin","pinchStart","e","getState","currentZoomLevel","contRect","getBoundingRect","center","origin","innerRect","getBoundingClientRect","left","top","_a","srcEvent","cancelable","preventDefault","stopPropagation","pinchMove","scale","pinchEnd","delta","requestZoomBy","vx","vy","async","Hammer","Promise","resolve","then","require","n","default","inputClass","SUPPORT_TOUCH","navigator","maxTouchPoints","test","userAgent","TouchInput","TouchMouseInput","MouseInput","touchAction","get","set","enable","pointers","threshold","on","error","console","warn","setupHammer","destroy","usePinch","provides","elementRef","useRef","useEffect","current","pageIndex","scaleOverride","className","stroke","fill","zoomPlugin","documentState","useDocumentState","rect","setRect","useState","actualScale","useMemo","registerMarqueeOnPage","callback","onPreview","jsx","position","pointerEvents","width","size","height","border","background","boxSizing","children","props","ref","display","overflow","margin","state","setState","initialDocumentState","scope","onStateChange","newState","usePlugin"],"mappings":"6MAIaA,EAAoB,IAAMC,gBAA0BC,EAAAA,WAAWC,ICMrE,SAASC,GAAeC,QAC7BA,EAAAC,WACAA,EAAAC,iBACAA,EAAAC,aACAA,IAEA,GAAsB,oBAAXC,OACT,MAAO,OAGT,IAAIC,EACAC,EAAc,EACdC,EAAa,CAAEC,EAAG,EAAGC,EAAG,GAE5B,MAAMC,EAAgBR,EAAiBS,YAAYV,GAC7CW,EAAYT,EAAaQ,YAAYV,GAQrCY,EAAiB,KACrBb,EAAQc,MAAMC,UAAY,OA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Cb,UAAsBuB,SAAEA,EAAApG,WAAUA,QAAYa,KAAUwF,IAC7D,MAAM9B,WAAEA,GAAeF,EAASrE,GAEhC,OACE2F,EAAAA,IAAC,MAAA,CACCW,IAAK/B,KACD8B,EACJxF,MAAO,IACFA,EACH0F,QAAS,QACTT,MAAO,cACPU,SAAU,UACVL,UAAW,aACXM,OAAQ,YAGTL,YAGP,qCJjBwBpG,IACtB,MAAMsE,SAAEA,GAAa5E,KACdgH,EAAOC,GAAYtB,EAAAA,SAA4BuB,EAAAA,sBAgBtD,OAdAnC,EAAAA,UAAU,KACR,IAAKH,EAAU,OAEf,MAAMuC,EAAQvC,EAAS5D,YAAYV,GAMnC,OAHA2G,EAASE,EAAM3F,YAGR2F,EAAMC,cAAeC,IAC1BJ,EAASI,MAEV,CAACzC,EAAUtE,IAEP,CACL0G,QACApC,UAAU,MAAAA,OAAA,EAAAA,EAAU5D,YAAYV,KAAe,yDA1BtB,IAAMgH,YAAsBpH,EAAAA,WAAWC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-zoom.ts","../../src/shared/utils/zoom-gesture-logic.ts","../../src/shared/hooks/use-zoom-gesture.ts","../../src/shared/components/marquee-zoom.tsx","../../src/shared/components/zoom-gesture-wrapper.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { initialDocumentState, ZoomDocumentState, ZoomPlugin } from '@embedpdf/plugin-zoom';\nimport { useEffect, useState } from '@framework';\n\nexport const useZoomCapability = () => useCapability<ZoomPlugin>(ZoomPlugin.id);\nexport const useZoomPlugin = () => usePlugin<ZoomPlugin>(ZoomPlugin.id);\n\n/**\n * Hook for zoom state for a specific document\n * @param documentId Document ID\n */\nexport const useZoom = (documentId: string) => {\n const { provides } = useZoomCapability();\n const [state, setState] = useState<ZoomDocumentState>(initialDocumentState);\n\n useEffect(() => {\n if (!provides) return;\n\n const scope = provides.forDocument(documentId);\n\n // Get initial state\n setState(scope.getState());\n\n // Subscribe to state changes\n return scope.onStateChange((newState) => {\n setState(newState);\n });\n }, [provides, documentId]);\n\n return {\n state,\n provides: provides?.forDocument(documentId) ?? null,\n };\n};\n","import type { ZoomCapability } from '@embedpdf/plugin-zoom';\n\nexport interface ZoomGestureOptions {\n /** Enable pinch-to-zoom gesture (default: true) */\n enablePinch?: boolean;\n /** Enable wheel zoom with ctrl/cmd key (default: true) */\n enableWheel?: boolean;\n}\n\nexport interface ZoomGestureDeps {\n element: HTMLDivElement;\n /** Viewport container element for attaching events */\n container: HTMLElement;\n documentId: string;\n zoomProvides: ZoomCapability;\n /** Viewport gap in pixels (default: 0) */\n viewportGap?: number;\n options?: ZoomGestureOptions;\n}\n\nfunction getTouchDistance(touches: TouchList): number {\n const [t1, t2] = [touches[0], touches[1]];\n const dx = t2.clientX - t1.clientX;\n const dy = t2.clientY - t1.clientY;\n return Math.hypot(dx, dy);\n}\n\nfunction getTouchCenter(touches: TouchList): { x: number; y: number } {\n const [t1, t2] = [touches[0], touches[1]];\n return {\n x: (t1.clientX + t2.clientX) / 2,\n y: (t1.clientY + t2.clientY) / 2,\n };\n}\n\nexport function setupZoomGestures({\n element,\n container,\n documentId,\n zoomProvides,\n viewportGap = 0,\n options = {},\n}: ZoomGestureDeps) {\n const { enablePinch = true, enableWheel = true } = options;\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const zoomScope = zoomProvides.forDocument(documentId);\n const getState = () => zoomScope.getState();\n\n // Shared state\n let initialZoom = 0;\n let currentScale = 1;\n let isPinching = false;\n let initialDistance = 0;\n\n // Wheel state\n let wheelZoomTimeout: ReturnType<typeof setTimeout> | null = null;\n let accumulatedWheelScale = 1;\n\n // Gesture state\n let initialElementWidth = 0;\n let initialElementHeight = 0;\n let initialElementLeft = 0;\n let initialElementTop = 0;\n\n // Container Dimensions (Bounding Box)\n let containerRectWidth = 0;\n let containerRectHeight = 0;\n\n // Layout Dimensions (Client Box from Metrics)\n let layoutWidth = 0;\n let layoutCenterX = 0;\n\n let pointerLocalY = 0;\n let pointerContainerX = 0;\n let pointerContainerY = 0;\n\n let currentGap = 0;\n let pivotLocalX = 0;\n\n const clamp = (val: number, min: number, max: number) => Math.min(Math.max(val, min), max);\n\n // --- Margin calculation ---\n const updateMargin = () => {\n const availableWidth = container.clientWidth - 2 * viewportGap;\n const elementWidth = element.offsetWidth;\n\n const newMargin = elementWidth < availableWidth ? (availableWidth - elementWidth) / 2 : 0;\n element.style.marginLeft = `${newMargin}px`;\n };\n\n const calculateTransform = (scale: number) => {\n const finalWidth = initialElementWidth * scale;\n const finalHeight = initialElementHeight * scale;\n\n let ty = pointerLocalY * (1 - scale);\n\n const targetX = layoutCenterX - finalWidth / 2;\n const txCenter = targetX - initialElementLeft;\n const txMouse = pointerContainerX - pivotLocalX * scale - initialElementLeft;\n\n const overflow = Math.max(0, finalWidth - layoutWidth);\n const blendRange = layoutWidth * 0.3;\n const blend = Math.min(1, overflow / blendRange);\n\n let tx = txCenter + (txMouse - txCenter) * blend;\n\n const safeHeight = containerRectHeight - currentGap * 2;\n if (finalHeight > safeHeight) {\n const currentTop = initialElementTop + ty;\n const maxTop = currentGap;\n const minTop = containerRectHeight - currentGap - finalHeight;\n const constrainedTop = clamp(currentTop, minTop, maxTop);\n ty = constrainedTop - initialElementTop;\n }\n\n const safeWidth = containerRectWidth - currentGap * 2;\n if (finalWidth > safeWidth) {\n const currentLeft = initialElementLeft + tx;\n const maxLeft = currentGap;\n const minLeft = containerRectWidth - currentGap - finalWidth;\n const constrainedLeft = clamp(currentLeft, minLeft, maxLeft);\n tx = constrainedLeft - initialElementLeft;\n }\n\n return { tx, ty, blend, finalWidth };\n };\n\n const updateTransform = (scale: number) => {\n currentScale = scale;\n const { tx, ty } = calculateTransform(scale);\n element.style.transformOrigin = '0 0';\n element.style.transform = `translate(${tx}px, ${ty}px) scale(${scale})`;\n };\n\n const resetTransform = () => {\n element.style.transform = 'none';\n element.style.transformOrigin = '0 0';\n currentScale = 1;\n };\n\n const commitZoom = () => {\n const { tx, finalWidth } = calculateTransform(currentScale);\n const delta = (currentScale - 1) * initialZoom;\n\n let anchorX: number;\n let anchorY: number = pointerContainerY;\n\n if (finalWidth <= layoutWidth) {\n anchorX = layoutCenterX;\n } else {\n const scaleDiff = 1 - currentScale;\n anchorX =\n Math.abs(scaleDiff) > 0.001 ? initialElementLeft + tx / scaleDiff : pointerContainerX;\n }\n\n zoomScope.requestZoomBy(delta, { vx: anchorX, vy: anchorY });\n resetTransform();\n initialZoom = 0;\n };\n\n const initializeGestureState = (clientX: number, clientY: number) => {\n const containerRect = container.getBoundingClientRect();\n const innerRect = element.getBoundingClientRect();\n\n currentGap = viewportGap;\n initialElementWidth = innerRect.width;\n initialElementHeight = innerRect.height;\n initialElementLeft = innerRect.left - containerRect.left;\n initialElementTop = innerRect.top - containerRect.top;\n\n containerRectWidth = containerRect.width;\n containerRectHeight = containerRect.height;\n\n // Layout dimensions from container's client area\n layoutWidth = container.clientWidth;\n layoutCenterX = container.clientLeft + layoutWidth / 2;\n\n const rawPointerLocalX = clientX - innerRect.left;\n pointerLocalY = clientY - innerRect.top;\n pointerContainerX = clientX - containerRect.left;\n pointerContainerY = clientY - containerRect.top;\n\n if (initialElementWidth < layoutWidth) {\n pivotLocalX = (pointerContainerX * initialElementWidth) / layoutWidth;\n } else {\n pivotLocalX = rawPointerLocalX;\n }\n };\n\n // --- Handlers ---\n const handleTouchStart = (e: TouchEvent) => {\n if (e.touches.length !== 2) return;\n isPinching = true;\n initialZoom = getState().currentZoomLevel;\n initialDistance = getTouchDistance(e.touches);\n const center = getTouchCenter(e.touches);\n initializeGestureState(center.x, center.y);\n e.preventDefault();\n };\n\n const handleTouchMove = (e: TouchEvent) => {\n if (!isPinching || e.touches.length !== 2) return;\n const currentDistance = getTouchDistance(e.touches);\n const scale = currentDistance / initialDistance;\n updateTransform(scale);\n e.preventDefault();\n };\n\n const handleTouchEnd = (e: TouchEvent) => {\n if (!isPinching) return;\n if (e.touches.length >= 2) return;\n isPinching = false;\n commitZoom();\n };\n\n const handleWheel = (e: WheelEvent) => {\n if (!e.ctrlKey && !e.metaKey) return;\n e.preventDefault();\n\n if (wheelZoomTimeout === null) {\n initialZoom = getState().currentZoomLevel;\n accumulatedWheelScale = 1;\n initializeGestureState(e.clientX, e.clientY);\n } else {\n clearTimeout(wheelZoomTimeout);\n }\n\n const zoomFactor = 1 - e.deltaY * 0.01;\n accumulatedWheelScale *= zoomFactor;\n accumulatedWheelScale = Math.max(0.1, Math.min(10, accumulatedWheelScale));\n updateTransform(accumulatedWheelScale);\n\n wheelZoomTimeout = setTimeout(() => {\n wheelZoomTimeout = null;\n commitZoom();\n accumulatedWheelScale = 1;\n }, 150);\n };\n\n // Subscribe to zoom changes to update margin\n const unsubZoom = zoomScope.onStateChange(() => updateMargin());\n\n // Use ResizeObserver to update margin when element or container size changes\n const resizeObserver = new ResizeObserver(() => updateMargin());\n resizeObserver.observe(element);\n resizeObserver.observe(container);\n\n // Initial margin calculation\n updateMargin();\n\n // Attach events to the viewport container for better UX\n // (gestures work anywhere in viewport, not just on the PDF)\n if (enablePinch) {\n container.addEventListener('touchstart', handleTouchStart, { passive: false });\n container.addEventListener('touchmove', handleTouchMove, { passive: false });\n container.addEventListener('touchend', handleTouchEnd);\n container.addEventListener('touchcancel', handleTouchEnd);\n }\n if (enableWheel) {\n container.addEventListener('wheel', handleWheel, { passive: false });\n }\n\n return () => {\n if (enablePinch) {\n container.removeEventListener('touchstart', handleTouchStart);\n container.removeEventListener('touchmove', handleTouchMove);\n container.removeEventListener('touchend', handleTouchEnd);\n container.removeEventListener('touchcancel', handleTouchEnd);\n }\n if (enableWheel) {\n container.removeEventListener('wheel', handleWheel);\n }\n if (wheelZoomTimeout) {\n clearTimeout(wheelZoomTimeout);\n }\n unsubZoom();\n resizeObserver.disconnect();\n resetTransform();\n element.style.marginLeft = '';\n };\n}\n","import { useLayoutEffect, useRef } from '@framework';\nimport { useCapability } from '@embedpdf/core/@framework';\nimport { ViewportPlugin, useViewportElement } from '@embedpdf/plugin-viewport/@framework';\nimport { setupZoomGestures, ZoomGestureOptions } from '../utils/zoom-gesture-logic';\nimport { useZoomCapability } from './use-zoom';\n\nexport type { ZoomGestureOptions };\n\nexport function useZoomGesture(documentId: string, options: ZoomGestureOptions = {}) {\n const { provides: viewportProvides } = useCapability<ViewportPlugin>('viewport');\n const { provides: zoomProvides } = useZoomCapability();\n const viewportElementRef = useViewportElement();\n const elementRef = useRef<HTMLDivElement>(null);\n\n // Use useLayoutEffect to set up zoom gestures synchronously before paint\n // This prevents flashing and layout jumps that occur with useEffect\n useLayoutEffect(() => {\n const element = elementRef.current;\n const container = viewportElementRef?.current;\n\n if (!element || !container || !zoomProvides) {\n return;\n }\n\n return setupZoomGestures({\n element,\n container,\n documentId,\n zoomProvides,\n viewportGap: viewportProvides?.getViewportGap() || 0,\n options,\n });\n }, [\n viewportProvides,\n zoomProvides,\n documentId,\n viewportElementRef,\n options.enablePinch,\n options.enableWheel,\n ]);\n\n return { elementRef };\n}\n","import { useEffect, useMemo, useState } from '@framework';\nimport { Rect } from '@embedpdf/models';\nimport { useZoomCapability } from '../hooks/use-zoom';\nimport { useDocumentState } from '@embedpdf/core/@framework';\n\ninterface MarqueeZoomProps {\n documentId: string;\n pageIndex: number;\n scale?: number;\n className?: string;\n stroke?: string;\n fill?: string;\n}\n\nexport const MarqueeZoom = ({\n documentId,\n pageIndex,\n scale: scaleOverride,\n className,\n stroke = 'rgba(33,150,243,0.8)',\n fill = 'rgba(33,150,243,0.15)',\n}: MarqueeZoomProps) => {\n const { provides: zoomPlugin } = useZoomCapability();\n const documentState = useDocumentState(documentId);\n const [rect, setRect] = useState<Rect | null>(null);\n\n const actualScale = useMemo(() => {\n if (scaleOverride !== undefined) return scaleOverride;\n return documentState?.scale ?? 1;\n }, [scaleOverride, documentState?.scale]);\n\n useEffect(() => {\n if (!zoomPlugin) return;\n return zoomPlugin.registerMarqueeOnPage({\n documentId,\n pageIndex,\n scale: actualScale,\n callback: {\n onPreview: setRect,\n },\n });\n }, [zoomPlugin, documentId, pageIndex, actualScale]);\n\n if (!rect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n pointerEvents: 'none',\n left: rect.origin.x * actualScale,\n top: rect.origin.y * actualScale,\n width: rect.size.width * actualScale,\n height: rect.size.height * actualScale,\n border: `1px solid ${stroke}`,\n background: fill,\n boxSizing: 'border-box',\n }}\n className={className}\n />\n );\n};\n","import { ReactNode, HTMLAttributes, CSSProperties, useMemo } from '@framework';\nimport { useZoomGesture, ZoomGestureOptions } from '../hooks';\n\ntype ZoomGestureWrapperProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ReactNode;\n documentId: string;\n style?: CSSProperties;\n /** Enable pinch-to-zoom gesture (default: true) */\n enablePinch?: boolean;\n /** Enable wheel zoom with ctrl/cmd key (default: true) */\n enableWheel?: boolean;\n};\n\nexport function ZoomGestureWrapper({\n children,\n documentId,\n style,\n enablePinch = true,\n enableWheel = true,\n ...props\n}: ZoomGestureWrapperProps) {\n const options = useMemo<ZoomGestureOptions>(\n () => ({ enablePinch, enableWheel }),\n [enablePinch, enableWheel],\n );\n const { elementRef } = useZoomGesture(documentId, options);\n\n return (\n <div\n ref={elementRef}\n {...props}\n style={{\n ...style,\n display: 'inline-block',\n overflow: 'visible',\n boxSizing: 'border-box',\n }}\n >\n {children}\n </div>\n );\n}\n"],"names":["useZoomCapability","useCapability","ZoomPlugin","id","getTouchDistance","touches","t1","t2","dx","clientX","dy","clientY","Math","hypot","useZoomGesture","documentId","options","provides","viewportProvides","zoomProvides","viewportElementRef","useViewportElement","elementRef","useRef","useLayoutEffect","element","current","container","viewportGap","enablePinch","enableWheel","window","zoomScope","forDocument","getState","initialZoom","currentScale","isPinching","initialDistance","wheelZoomTimeout","accumulatedWheelScale","initialElementWidth","initialElementHeight","initialElementLeft","initialElementTop","containerRectWidth","containerRectHeight","layoutWidth","layoutCenterX","pointerLocalY","pointerContainerX","pointerContainerY","currentGap","pivotLocalX","clamp","val","min","max","updateMargin","availableWidth","clientWidth","elementWidth","offsetWidth","newMargin","style","marginLeft","calculateTransform","scale","finalWidth","finalHeight","ty","txCenter","txMouse","overflow","blendRange","blend","tx","updateTransform","transformOrigin","transform","resetTransform","commitZoom","delta","anchorX","anchorY","scaleDiff","abs","requestZoomBy","vx","vy","initializeGestureState","containerRect","getBoundingClientRect","innerRect","width","height","left","top","clientLeft","rawPointerLocalX","handleTouchStart","e","length","currentZoomLevel","center","x","y","getTouchCenter","preventDefault","handleTouchMove","currentDistance","handleTouchEnd","handleWheel","ctrlKey","metaKey","clearTimeout","zoomFactor","deltaY","setTimeout","unsubZoom","onStateChange","resizeObserver","ResizeObserver","observe","addEventListener","passive","removeEventListener","disconnect","setupZoomGestures","getViewportGap","pageIndex","scaleOverride","className","stroke","fill","zoomPlugin","documentState","useDocumentState","rect","setRect","useState","actualScale","useMemo","useEffect","registerMarqueeOnPage","callback","onPreview","jsx","position","pointerEvents","origin","size","border","background","boxSizing","children","props","ref","display","state","setState","initialDocumentState","scope","newState","usePlugin"],"mappings":"0PAIaA,EAAoB,IAAMC,gBAA0BC,EAAAA,WAAWC,ICgB5E,SAASC,EAAiBC,GACxB,MAAOC,EAAIC,GAAM,CAACF,EAAQ,GAAIA,EAAQ,IAChCG,EAAKD,EAAGE,QAAUH,EAAGG,QACrBC,EAAKH,EAAGI,QAAUL,EAAGK,QAC3B,OAAOC,KAAKC,MAAML,EAAIE,EACxB,CCjBO,SAASI,EAAeC,EAAoBC,EAA8B,IAC/E,MAAQC,SAAUC,GAAqBjB,EAAAA,cAA8B,aAC7DgB,SAAUE,GAAiBnB,IAC7BoB,EAAqBC,EAAAA,qBACrBC,EAAaC,EAAAA,OAAuB,MA6B1C,OAzBAC,EAAAA,gBAAgB,KACd,MAAMC,EAAUH,EAAWI,QACrBC,EAAY,MAAAP,OAAA,EAAAA,EAAoBM,QAEtC,GAAKD,GAAYE,GAAcR,EAI/B,ODWG,UAA2BM,QAChCA,EAAAE,UACAA,EAA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,cAAe,OACfrD,KAAM0C,EAAKY,OAAO7C,EAAIoC,EACtB5C,IAAKyC,EAAKY,OAAO5C,EAAImC,EACrB/C,MAAO4C,EAAKa,KAAKzD,MAAQ+C,EACzB9C,OAAQ2C,EAAKa,KAAKxD,OAAS8C,EAC3BW,OAAQ,aAAanB,IACrBoB,WAAYnB,EACZoB,UAAW,cAEbtB,cAfc,iCC9Bb,UAA4BuB,SACjCA,EAAA5I,WACAA,EAAAiD,MACAA,EAAAnC,YACAA,GAAc,EAAAC,YACdA,GAAc,KACX8H,IAEH,MAAM5I,EAAU8H,EAAAA,QACd,KAAA,CAASjH,cAAaC,gBACtB,CAACD,EAAaC,KAEVR,WAAEA,GAAeR,EAAeC,EAAYC,GAElD,OACEmI,EAAAA,IAAC,MAAA,CACCU,IAAKvI,KACDsI,EACJ5F,MAAO,IACFA,EACH8F,QAAS,eACTrF,SAAU,UACViF,UAAW,cAGZC,YAGP,kBJ9BwB5I,IACtB,MAAME,SAAEA,GAAajB,KACd+J,EAAOC,GAAYpB,EAAAA,SAA4BqB,EAAAA,sBAgBtD,OAdAlB,EAAAA,UAAU,KACR,IAAK9H,EAAU,OAEf,MAAMiJ,EAAQjJ,EAASgB,YAAYlB,GAMnC,OAHAiJ,EAASE,EAAMhI,YAGRgI,EAAM1C,cAAe2C,IAC1BH,EAASG,MAEV,CAAClJ,EAAUF,IAEP,CACLgJ,QACA9I,UAAU,MAAAA,OAAA,EAAAA,EAAUgB,YAAYlB,KAAe,kFA1BtB,IAAMqJ,YAAsBlK,EAAAA,WAAWC"}
|
package/dist/react/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useCapability, usePlugin, useDocumentState } from "@embedpdf/core/react";
|
|
2
2
|
import { ZoomPlugin, initialDocumentState } from "@embedpdf/plugin-zoom";
|
|
3
3
|
export * from "@embedpdf/plugin-zoom";
|
|
4
|
-
import { useState, useEffect, useRef, useMemo } from "react";
|
|
4
|
+
import { useState, useEffect, useRef, useLayoutEffect, useMemo } from "react";
|
|
5
|
+
import { useViewportElement } from "@embedpdf/plugin-viewport/react";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
const useZoomCapability = () => useCapability(ZoomPlugin.id);
|
|
7
8
|
const useZoomPlugin = () => usePlugin(ZoomPlugin.id);
|
|
@@ -21,107 +22,254 @@ const useZoom = (documentId) => {
|
|
|
21
22
|
provides: (provides == null ? void 0 : provides.forDocument(documentId)) ?? null
|
|
22
23
|
};
|
|
23
24
|
};
|
|
24
|
-
function
|
|
25
|
+
function getTouchDistance(touches) {
|
|
26
|
+
const [t1, t2] = [touches[0], touches[1]];
|
|
27
|
+
const dx = t2.clientX - t1.clientX;
|
|
28
|
+
const dy = t2.clientY - t1.clientY;
|
|
29
|
+
return Math.hypot(dx, dy);
|
|
30
|
+
}
|
|
31
|
+
function getTouchCenter(touches) {
|
|
32
|
+
const [t1, t2] = [touches[0], touches[1]];
|
|
33
|
+
return {
|
|
34
|
+
x: (t1.clientX + t2.clientX) / 2,
|
|
35
|
+
y: (t1.clientY + t2.clientY) / 2
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function setupZoomGestures({
|
|
25
39
|
element,
|
|
40
|
+
container,
|
|
26
41
|
documentId,
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
zoomProvides,
|
|
43
|
+
viewportGap = 0,
|
|
44
|
+
options = {}
|
|
29
45
|
}) {
|
|
46
|
+
const { enablePinch = true, enableWheel = true } = options;
|
|
30
47
|
if (typeof window === "undefined") {
|
|
31
48
|
return () => {
|
|
32
49
|
};
|
|
33
50
|
}
|
|
34
|
-
let hammer;
|
|
35
|
-
let initialZoom = 0;
|
|
36
|
-
let lastCenter = { x: 0, y: 0 };
|
|
37
|
-
const viewportScope = viewportProvides.forDocument(documentId);
|
|
38
51
|
const zoomScope = zoomProvides.forDocument(documentId);
|
|
39
52
|
const getState = () => zoomScope.getState();
|
|
53
|
+
let initialZoom = 0;
|
|
54
|
+
let currentScale = 1;
|
|
55
|
+
let isPinching = false;
|
|
56
|
+
let initialDistance = 0;
|
|
57
|
+
let wheelZoomTimeout = null;
|
|
58
|
+
let accumulatedWheelScale = 1;
|
|
59
|
+
let initialElementWidth = 0;
|
|
60
|
+
let initialElementHeight = 0;
|
|
61
|
+
let initialElementLeft = 0;
|
|
62
|
+
let initialElementTop = 0;
|
|
63
|
+
let containerRectWidth = 0;
|
|
64
|
+
let containerRectHeight = 0;
|
|
65
|
+
let layoutWidth = 0;
|
|
66
|
+
let layoutCenterX = 0;
|
|
67
|
+
let pointerLocalY = 0;
|
|
68
|
+
let pointerContainerX = 0;
|
|
69
|
+
let pointerContainerY = 0;
|
|
70
|
+
let currentGap = 0;
|
|
71
|
+
let pivotLocalX = 0;
|
|
72
|
+
const clamp = (val, min, max) => Math.min(Math.max(val, min), max);
|
|
73
|
+
const updateMargin = () => {
|
|
74
|
+
const availableWidth = container.clientWidth - 2 * viewportGap;
|
|
75
|
+
const elementWidth = element.offsetWidth;
|
|
76
|
+
const newMargin = elementWidth < availableWidth ? (availableWidth - elementWidth) / 2 : 0;
|
|
77
|
+
element.style.marginLeft = `${newMargin}px`;
|
|
78
|
+
};
|
|
79
|
+
const calculateTransform = (scale) => {
|
|
80
|
+
const finalWidth = initialElementWidth * scale;
|
|
81
|
+
const finalHeight = initialElementHeight * scale;
|
|
82
|
+
let ty = pointerLocalY * (1 - scale);
|
|
83
|
+
const targetX = layoutCenterX - finalWidth / 2;
|
|
84
|
+
const txCenter = targetX - initialElementLeft;
|
|
85
|
+
const txMouse = pointerContainerX - pivotLocalX * scale - initialElementLeft;
|
|
86
|
+
const overflow = Math.max(0, finalWidth - layoutWidth);
|
|
87
|
+
const blendRange = layoutWidth * 0.3;
|
|
88
|
+
const blend = Math.min(1, overflow / blendRange);
|
|
89
|
+
let tx = txCenter + (txMouse - txCenter) * blend;
|
|
90
|
+
const safeHeight = containerRectHeight - currentGap * 2;
|
|
91
|
+
if (finalHeight > safeHeight) {
|
|
92
|
+
const currentTop = initialElementTop + ty;
|
|
93
|
+
const maxTop = currentGap;
|
|
94
|
+
const minTop = containerRectHeight - currentGap - finalHeight;
|
|
95
|
+
const constrainedTop = clamp(currentTop, minTop, maxTop);
|
|
96
|
+
ty = constrainedTop - initialElementTop;
|
|
97
|
+
}
|
|
98
|
+
const safeWidth = containerRectWidth - currentGap * 2;
|
|
99
|
+
if (finalWidth > safeWidth) {
|
|
100
|
+
const currentLeft = initialElementLeft + tx;
|
|
101
|
+
const maxLeft = currentGap;
|
|
102
|
+
const minLeft = containerRectWidth - currentGap - finalWidth;
|
|
103
|
+
const constrainedLeft = clamp(currentLeft, minLeft, maxLeft);
|
|
104
|
+
tx = constrainedLeft - initialElementLeft;
|
|
105
|
+
}
|
|
106
|
+
return { tx, ty, blend, finalWidth };
|
|
107
|
+
};
|
|
40
108
|
const updateTransform = (scale) => {
|
|
41
|
-
|
|
109
|
+
currentScale = scale;
|
|
110
|
+
const { tx, ty } = calculateTransform(scale);
|
|
111
|
+
element.style.transformOrigin = "0 0";
|
|
112
|
+
element.style.transform = `translate(${tx}px, ${ty}px) scale(${scale})`;
|
|
42
113
|
};
|
|
43
114
|
const resetTransform = () => {
|
|
44
115
|
element.style.transform = "none";
|
|
45
116
|
element.style.transformOrigin = "0 0";
|
|
117
|
+
currentScale = 1;
|
|
46
118
|
};
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if ((_a = e.srcEvent) == null ? void 0 : _a.cancelable) {
|
|
58
|
-
e.srcEvent.preventDefault();
|
|
59
|
-
e.srcEvent.stopPropagation();
|
|
119
|
+
const commitZoom = () => {
|
|
120
|
+
const { tx, finalWidth } = calculateTransform(currentScale);
|
|
121
|
+
const delta = (currentScale - 1) * initialZoom;
|
|
122
|
+
let anchorX;
|
|
123
|
+
let anchorY = pointerContainerY;
|
|
124
|
+
if (finalWidth <= layoutWidth) {
|
|
125
|
+
anchorX = layoutCenterX;
|
|
126
|
+
} else {
|
|
127
|
+
const scaleDiff = 1 - currentScale;
|
|
128
|
+
anchorX = Math.abs(scaleDiff) > 1e-3 ? initialElementLeft + tx / scaleDiff : pointerContainerX;
|
|
60
129
|
}
|
|
130
|
+
zoomScope.requestZoomBy(delta, { vx: anchorX, vy: anchorY });
|
|
131
|
+
resetTransform();
|
|
132
|
+
initialZoom = 0;
|
|
61
133
|
};
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
134
|
+
const initializeGestureState = (clientX, clientY) => {
|
|
135
|
+
const containerRect = container.getBoundingClientRect();
|
|
136
|
+
const innerRect = element.getBoundingClientRect();
|
|
137
|
+
currentGap = viewportGap;
|
|
138
|
+
initialElementWidth = innerRect.width;
|
|
139
|
+
initialElementHeight = innerRect.height;
|
|
140
|
+
initialElementLeft = innerRect.left - containerRect.left;
|
|
141
|
+
initialElementTop = innerRect.top - containerRect.top;
|
|
142
|
+
containerRectWidth = containerRect.width;
|
|
143
|
+
containerRectHeight = containerRect.height;
|
|
144
|
+
layoutWidth = container.clientWidth;
|
|
145
|
+
layoutCenterX = container.clientLeft + layoutWidth / 2;
|
|
146
|
+
const rawPointerLocalX = clientX - innerRect.left;
|
|
147
|
+
pointerLocalY = clientY - innerRect.top;
|
|
148
|
+
pointerContainerX = clientX - containerRect.left;
|
|
149
|
+
pointerContainerY = clientY - containerRect.top;
|
|
150
|
+
if (initialElementWidth < layoutWidth) {
|
|
151
|
+
pivotLocalX = pointerContainerX * initialElementWidth / layoutWidth;
|
|
152
|
+
} else {
|
|
153
|
+
pivotLocalX = rawPointerLocalX;
|
|
68
154
|
}
|
|
69
155
|
};
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
156
|
+
const handleTouchStart = (e) => {
|
|
157
|
+
if (e.touches.length !== 2) return;
|
|
158
|
+
isPinching = true;
|
|
159
|
+
initialZoom = getState().currentZoomLevel;
|
|
160
|
+
initialDistance = getTouchDistance(e.touches);
|
|
161
|
+
const center = getTouchCenter(e.touches);
|
|
162
|
+
initializeGestureState(center.x, center.y);
|
|
163
|
+
e.preventDefault();
|
|
75
164
|
};
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
165
|
+
const handleTouchMove = (e) => {
|
|
166
|
+
if (!isPinching || e.touches.length !== 2) return;
|
|
167
|
+
const currentDistance = getTouchDistance(e.touches);
|
|
168
|
+
const scale = currentDistance / initialDistance;
|
|
169
|
+
updateTransform(scale);
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
};
|
|
172
|
+
const handleTouchEnd = (e) => {
|
|
173
|
+
if (!isPinching) return;
|
|
174
|
+
if (e.touches.length >= 2) return;
|
|
175
|
+
isPinching = false;
|
|
176
|
+
commitZoom();
|
|
177
|
+
};
|
|
178
|
+
const handleWheel = (e) => {
|
|
179
|
+
if (!e.ctrlKey && !e.metaKey) return;
|
|
180
|
+
e.preventDefault();
|
|
181
|
+
if (wheelZoomTimeout === null) {
|
|
182
|
+
initialZoom = getState().currentZoomLevel;
|
|
183
|
+
accumulatedWheelScale = 1;
|
|
184
|
+
initializeGestureState(e.clientX, e.clientY);
|
|
185
|
+
} else {
|
|
186
|
+
clearTimeout(wheelZoomTimeout);
|
|
97
187
|
}
|
|
188
|
+
const zoomFactor = 1 - e.deltaY * 0.01;
|
|
189
|
+
accumulatedWheelScale *= zoomFactor;
|
|
190
|
+
accumulatedWheelScale = Math.max(0.1, Math.min(10, accumulatedWheelScale));
|
|
191
|
+
updateTransform(accumulatedWheelScale);
|
|
192
|
+
wheelZoomTimeout = setTimeout(() => {
|
|
193
|
+
wheelZoomTimeout = null;
|
|
194
|
+
commitZoom();
|
|
195
|
+
accumulatedWheelScale = 1;
|
|
196
|
+
}, 150);
|
|
98
197
|
};
|
|
99
|
-
|
|
198
|
+
const unsubZoom = zoomScope.onStateChange(() => updateMargin());
|
|
199
|
+
const resizeObserver = new ResizeObserver(() => updateMargin());
|
|
200
|
+
resizeObserver.observe(element);
|
|
201
|
+
resizeObserver.observe(container);
|
|
202
|
+
updateMargin();
|
|
203
|
+
if (enablePinch) {
|
|
204
|
+
container.addEventListener("touchstart", handleTouchStart, { passive: false });
|
|
205
|
+
container.addEventListener("touchmove", handleTouchMove, { passive: false });
|
|
206
|
+
container.addEventListener("touchend", handleTouchEnd);
|
|
207
|
+
container.addEventListener("touchcancel", handleTouchEnd);
|
|
208
|
+
}
|
|
209
|
+
if (enableWheel) {
|
|
210
|
+
container.addEventListener("wheel", handleWheel, { passive: false });
|
|
211
|
+
}
|
|
100
212
|
return () => {
|
|
101
|
-
|
|
213
|
+
if (enablePinch) {
|
|
214
|
+
container.removeEventListener("touchstart", handleTouchStart);
|
|
215
|
+
container.removeEventListener("touchmove", handleTouchMove);
|
|
216
|
+
container.removeEventListener("touchend", handleTouchEnd);
|
|
217
|
+
container.removeEventListener("touchcancel", handleTouchEnd);
|
|
218
|
+
}
|
|
219
|
+
if (enableWheel) {
|
|
220
|
+
container.removeEventListener("wheel", handleWheel);
|
|
221
|
+
}
|
|
222
|
+
if (wheelZoomTimeout) {
|
|
223
|
+
clearTimeout(wheelZoomTimeout);
|
|
224
|
+
}
|
|
225
|
+
unsubZoom();
|
|
226
|
+
resizeObserver.disconnect();
|
|
102
227
|
resetTransform();
|
|
228
|
+
element.style.marginLeft = "";
|
|
103
229
|
};
|
|
104
230
|
}
|
|
105
|
-
function
|
|
231
|
+
function useZoomGesture(documentId, options = {}) {
|
|
106
232
|
const { provides: viewportProvides } = useCapability("viewport");
|
|
107
233
|
const { provides: zoomProvides } = useZoomCapability();
|
|
234
|
+
const viewportElementRef = useViewportElement();
|
|
108
235
|
const elementRef = useRef(null);
|
|
109
|
-
|
|
236
|
+
useLayoutEffect(() => {
|
|
110
237
|
const element = elementRef.current;
|
|
111
|
-
|
|
238
|
+
const container = viewportElementRef == null ? void 0 : viewportElementRef.current;
|
|
239
|
+
if (!element || !container || !zoomProvides) {
|
|
112
240
|
return;
|
|
113
241
|
}
|
|
114
|
-
return
|
|
242
|
+
return setupZoomGestures({
|
|
115
243
|
element,
|
|
244
|
+
container,
|
|
116
245
|
documentId,
|
|
117
|
-
|
|
118
|
-
|
|
246
|
+
zoomProvides,
|
|
247
|
+
viewportGap: (viewportProvides == null ? void 0 : viewportProvides.getViewportGap()) || 0,
|
|
248
|
+
options
|
|
119
249
|
});
|
|
120
|
-
}, [
|
|
250
|
+
}, [
|
|
251
|
+
viewportProvides,
|
|
252
|
+
zoomProvides,
|
|
253
|
+
documentId,
|
|
254
|
+
viewportElementRef,
|
|
255
|
+
options.enablePinch,
|
|
256
|
+
options.enableWheel
|
|
257
|
+
]);
|
|
121
258
|
return { elementRef };
|
|
122
259
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
260
|
+
function ZoomGestureWrapper({
|
|
261
|
+
children,
|
|
262
|
+
documentId,
|
|
263
|
+
style,
|
|
264
|
+
enablePinch = true,
|
|
265
|
+
enableWheel = true,
|
|
266
|
+
...props
|
|
267
|
+
}) {
|
|
268
|
+
const options = useMemo(
|
|
269
|
+
() => ({ enablePinch, enableWheel }),
|
|
270
|
+
[enablePinch, enableWheel]
|
|
271
|
+
);
|
|
272
|
+
const { elementRef } = useZoomGesture(documentId, options);
|
|
125
273
|
return /* @__PURE__ */ jsx(
|
|
126
274
|
"div",
|
|
127
275
|
{
|
|
@@ -129,11 +277,9 @@ function PinchWrapper({ children, documentId, style, ...props }) {
|
|
|
129
277
|
...props,
|
|
130
278
|
style: {
|
|
131
279
|
...style,
|
|
132
|
-
display: "block",
|
|
133
|
-
width: "fit-content",
|
|
280
|
+
display: "inline-block",
|
|
134
281
|
overflow: "visible",
|
|
135
|
-
boxSizing: "border-box"
|
|
136
|
-
margin: "0px auto"
|
|
282
|
+
boxSizing: "border-box"
|
|
137
283
|
},
|
|
138
284
|
children
|
|
139
285
|
}
|
|
@@ -186,10 +332,10 @@ const MarqueeZoom = ({
|
|
|
186
332
|
};
|
|
187
333
|
export {
|
|
188
334
|
MarqueeZoom,
|
|
189
|
-
|
|
190
|
-
usePinch,
|
|
335
|
+
ZoomGestureWrapper,
|
|
191
336
|
useZoom,
|
|
192
337
|
useZoomCapability,
|
|
338
|
+
useZoomGesture,
|
|
193
339
|
useZoomPlugin
|
|
194
340
|
};
|
|
195
341
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-zoom.ts","../../src/shared/utils/pinch-zoom-logic.ts","../../src/shared/hooks/use-pinch-zoom.ts","../../src/shared/components/pinch-wrapper.tsx","../../src/shared/components/marquee-zoom.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { initialDocumentState, ZoomDocumentState, ZoomPlugin } from '@embedpdf/plugin-zoom';\nimport { useEffect, useState } from '@framework';\n\nexport const useZoomCapability = () => useCapability<ZoomPlugin>(ZoomPlugin.id);\nexport const useZoomPlugin = () => usePlugin<ZoomPlugin>(ZoomPlugin.id);\n\n/**\n * Hook for zoom state for a specific document\n * @param documentId Document ID\n */\nexport const useZoom = (documentId: string) => {\n const { provides } = useZoomCapability();\n const [state, setState] = useState<ZoomDocumentState>(initialDocumentState);\n\n useEffect(() => {\n if (!provides) return;\n\n const scope = provides.forDocument(documentId);\n\n // Get initial state\n setState(scope.getState());\n\n // Subscribe to state changes\n return scope.onStateChange((newState) => {\n setState(newState);\n });\n }, [provides, documentId]);\n\n return {\n state,\n provides: provides?.forDocument(documentId) ?? null,\n };\n};\n","import type { ViewportCapability } from '@embedpdf/plugin-viewport';\nimport type { ZoomCapability } from '@embedpdf/plugin-zoom';\n\nexport interface PinchZoomDeps {\n element: HTMLDivElement;\n documentId: string;\n viewportProvides: ViewportCapability;\n zoomProvides: ZoomCapability;\n}\n\nexport function setupPinchZoom({\n element,\n documentId,\n viewportProvides,\n zoomProvides,\n}: PinchZoomDeps) {\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n let hammer: any | undefined;\n let initialZoom = 0;\n let lastCenter = { x: 0, y: 0 };\n\n const viewportScope = viewportProvides.forDocument(documentId);\n const zoomScope = zoomProvides.forDocument(documentId);\n\n const getState = () => zoomScope.getState();\n\n const updateTransform = (scale: number) => {\n element.style.transform = `scale(${scale})`;\n };\n\n const resetTransform = () => {\n element.style.transform = 'none';\n element.style.transformOrigin = '0 0';\n };\n\n const pinchStart = (e: HammerInput) => {\n initialZoom = getState().currentZoomLevel;\n\n const contRect = viewportScope.getBoundingRect();\n\n lastCenter = {\n x: e.center.x - contRect.origin.x,\n y: e.center.y - contRect.origin.y,\n };\n\n const innerRect = element.getBoundingClientRect();\n element.style.transformOrigin = `${e.center.x - innerRect.left}px ${e.center.y - innerRect.top}px`;\n\n if (e.srcEvent?.cancelable) {\n e.srcEvent.preventDefault();\n e.srcEvent.stopPropagation();\n }\n };\n\n const pinchMove = (e: HammerInput) => {\n updateTransform(e.scale);\n if (e.srcEvent?.cancelable) {\n e.srcEvent.preventDefault();\n e.srcEvent.stopPropagation();\n }\n };\n\n const pinchEnd = (e: HammerInput) => {\n const delta = (e.scale - 1) * initialZoom;\n zoomScope.requestZoomBy(delta, { vx: lastCenter.x, vy: lastCenter.y });\n\n resetTransform();\n initialZoom = 0;\n };\n\n const setupHammer = async () => {\n try {\n const Hammer = (await import('hammerjs')).default;\n\n const inputClass = (() => {\n const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;\n const SUPPORT_TOUCH = 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n const SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);\n if (SUPPORT_ONLY_TOUCH) return Hammer.TouchInput;\n if (!SUPPORT_TOUCH) return Hammer.MouseInput;\n return Hammer.TouchMouseInput;\n })();\n\n hammer = new Hammer(element, {\n touchAction: 'pan-x pan-y',\n inputClass,\n });\n\n hammer.get('pinch').set({ enable: true, pointers: 2, threshold: 0.1 });\n\n hammer.on('pinchstart', pinchStart);\n hammer.on('pinchmove', pinchMove);\n hammer.on('pinchend', pinchEnd);\n } catch (error) {\n console.warn('Failed to load HammerJS:', error);\n }\n };\n\n setupHammer();\n\n return () => {\n hammer?.destroy();\n resetTransform();\n };\n}\n","import { useEffect, useRef } from '@framework';\nimport { useCapability } from '@embedpdf/core/@framework';\nimport { ViewportPlugin } from '@embedpdf/plugin-viewport';\nimport { setupPinchZoom } from '../utils/pinch-zoom-logic';\nimport { useZoomCapability } from './use-zoom';\n\nexport function usePinch(documentId: string) {\n const { provides: viewportProvides } = useCapability<ViewportPlugin>('viewport');\n const { provides: zoomProvides } = useZoomCapability();\n const elementRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const element = elementRef.current;\n if (!element || !viewportProvides || !zoomProvides) {\n return;\n }\n\n return setupPinchZoom({\n element,\n documentId,\n viewportProvides,\n zoomProvides,\n });\n }, [viewportProvides, zoomProvides, documentId]);\n\n return { elementRef };\n}\n","import { ReactNode, HTMLAttributes, CSSProperties } from '@framework';\nimport { usePinch } from '../hooks';\n\ntype PinchWrapperProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ReactNode;\n documentId: string;\n style?: CSSProperties;\n};\n\nexport function PinchWrapper({ children, documentId, style, ...props }: PinchWrapperProps) {\n const { elementRef } = usePinch(documentId);\n\n return (\n <div\n ref={elementRef}\n {...props}\n style={{\n ...style,\n display: 'block',\n width: 'fit-content',\n overflow: 'visible',\n boxSizing: 'border-box',\n margin: '0px auto',\n }}\n >\n {children}\n </div>\n );\n}\n","import { useEffect, useMemo, useState } from '@framework';\nimport { Rect } from '@embedpdf/models';\nimport { useZoomCapability } from '../hooks/use-zoom';\nimport { useDocumentState } from '@embedpdf/core/@framework';\n\ninterface MarqueeZoomProps {\n documentId: string;\n pageIndex: number;\n scale?: number;\n className?: string;\n stroke?: string;\n fill?: string;\n}\n\nexport const MarqueeZoom = ({\n documentId,\n pageIndex,\n scale: scaleOverride,\n className,\n stroke = 'rgba(33,150,243,0.8)',\n fill = 'rgba(33,150,243,0.15)',\n}: MarqueeZoomProps) => {\n const { provides: zoomPlugin } = useZoomCapability();\n const documentState = useDocumentState(documentId);\n const [rect, setRect] = useState<Rect | null>(null);\n\n const actualScale = useMemo(() => {\n if (scaleOverride !== undefined) return scaleOverride;\n return documentState?.scale ?? 1;\n }, [scaleOverride, documentState?.scale]);\n\n useEffect(() => {\n if (!zoomPlugin) return;\n return zoomPlugin.registerMarqueeOnPage({\n documentId,\n pageIndex,\n scale: actualScale,\n callback: {\n onPreview: setRect,\n },\n });\n }, [zoomPlugin, documentId, pageIndex, actualScale]);\n\n if (!rect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n pointerEvents: 'none',\n left: rect.origin.x * actualScale,\n top: rect.origin.y * actualScale,\n width: rect.size.width * actualScale,\n height: rect.size.height * actualScale,\n border: `1px solid ${stroke}`,\n background: fill,\n boxSizing: 'border-box',\n }}\n className={className}\n />\n );\n};\n"],"names":[],"mappings":";;;;;AAIO,MAAM,oBAAoB,MAAM,cAA0B,WAAW,EAAE;AACvE,MAAM,gBAAgB,MAAM,UAAsB,WAAW,EAAE;AAM/D,MAAM,UAAU,CAAC,eAAuB;AAC7C,QAAM,EAAE,SAAA,IAAa,kBAAA;AACrB,QAAM,CAAC,OAAO,QAAQ,IAAI,SAA4B,oBAAoB;AAE1E,YAAU,MAAM;AACd,QAAI,CAAC,SAAU;AAEf,UAAM,QAAQ,SAAS,YAAY,UAAU;AAG7C,a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E;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,UAAU;AAAA,QACV,eAAe;AAAA,QACf,MAAM,KAAK,OAAO,IAAI;AAAA,QACtB,KAAK,KAAK,OAAO,IAAI;AAAA,QACrB,OAAO,KAAK,KAAK,QAAQ;AAAA,QACzB,QAAQ,KAAK,KAAK,SAAS;AAAA,QAC3B,QAAQ,aAAa,MAAM;AAAA,QAC3B,YAAY;AAAA,QACZ,WAAW;AAAA,MAAA;AAAA,MAEb;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-zoom.ts","../../src/shared/utils/zoom-gesture-logic.ts","../../src/shared/hooks/use-zoom-gesture.ts","../../src/shared/components/zoom-gesture-wrapper.tsx","../../src/shared/components/marquee-zoom.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { initialDocumentState, ZoomDocumentState, ZoomPlugin } from '@embedpdf/plugin-zoom';\nimport { useEffect, useState } from '@framework';\n\nexport const useZoomCapability = () => useCapability<ZoomPlugin>(ZoomPlugin.id);\nexport const useZoomPlugin = () => usePlugin<ZoomPlugin>(ZoomPlugin.id);\n\n/**\n * Hook for zoom state for a specific document\n * @param documentId Document ID\n */\nexport const useZoom = (documentId: string) => {\n const { provides } = useZoomCapability();\n const [state, setState] = useState<ZoomDocumentState>(initialDocumentState);\n\n useEffect(() => {\n if (!provides) return;\n\n const scope = provides.forDocument(documentId);\n\n // Get initial state\n setState(scope.getState());\n\n // Subscribe to state changes\n return scope.onStateChange((newState) => {\n setState(newState);\n });\n }, [provides, documentId]);\n\n return {\n state,\n provides: provides?.forDocument(documentId) ?? null,\n };\n};\n","import type { ZoomCapability } from '@embedpdf/plugin-zoom';\n\nexport interface ZoomGestureOptions {\n /** Enable pinch-to-zoom gesture (default: true) */\n enablePinch?: boolean;\n /** Enable wheel zoom with ctrl/cmd key (default: true) */\n enableWheel?: boolean;\n}\n\nexport interface ZoomGestureDeps {\n element: HTMLDivElement;\n /** Viewport container element for attaching events */\n container: HTMLElement;\n documentId: string;\n zoomProvides: ZoomCapability;\n /** Viewport gap in pixels (default: 0) */\n viewportGap?: number;\n options?: ZoomGestureOptions;\n}\n\nfunction getTouchDistance(touches: TouchList): number {\n const [t1, t2] = [touches[0], touches[1]];\n const dx = t2.clientX - t1.clientX;\n const dy = t2.clientY - t1.clientY;\n return Math.hypot(dx, dy);\n}\n\nfunction getTouchCenter(touches: TouchList): { x: number; y: number } {\n const [t1, t2] = [touches[0], touches[1]];\n return {\n x: (t1.clientX + t2.clientX) / 2,\n y: (t1.clientY + t2.clientY) / 2,\n };\n}\n\nexport function setupZoomGestures({\n element,\n container,\n documentId,\n zoomProvides,\n viewportGap = 0,\n options = {},\n}: ZoomGestureDeps) {\n const { enablePinch = true, enableWheel = true } = options;\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const zoomScope = zoomProvides.forDocument(documentId);\n const getState = () => zoomScope.getState();\n\n // Shared state\n let initialZoom = 0;\n let currentScale = 1;\n let isPinching = false;\n let initialDistance = 0;\n\n // Wheel state\n let wheelZoomTimeout: ReturnType<typeof setTimeout> | null = null;\n let accumulatedWheelScale = 1;\n\n // Gesture state\n let initialElementWidth = 0;\n let initialElementHeight = 0;\n let initialElementLeft = 0;\n let initialElementTop = 0;\n\n // Container Dimensions (Bounding Box)\n let containerRectWidth = 0;\n let containerRectHeight = 0;\n\n // Layout Dimensions (Client Box from Metrics)\n let layoutWidth = 0;\n let layoutCenterX = 0;\n\n let pointerLocalY = 0;\n let pointerContainerX = 0;\n let pointerContainerY = 0;\n\n let currentGap = 0;\n let pivotLocalX = 0;\n\n const clamp = (val: number, min: number, max: number) => Math.min(Math.max(val, min), max);\n\n // --- Margin calculation ---\n const updateMargin = () => {\n const availableWidth = container.clientWidth - 2 * viewportGap;\n const elementWidth = element.offsetWidth;\n\n const newMargin = elementWidth < availableWidth ? (availableWidth - elementWidth) / 2 : 0;\n element.style.marginLeft = `${newMargin}px`;\n };\n\n const calculateTransform = (scale: number) => {\n const finalWidth = initialElementWidth * scale;\n const finalHeight = initialElementHeight * scale;\n\n let ty = pointerLocalY * (1 - scale);\n\n const targetX = layoutCenterX - finalWidth / 2;\n const txCenter = targetX - initialElementLeft;\n const txMouse = pointerContainerX - pivotLocalX * scale - initialElementLeft;\n\n const overflow = Math.max(0, finalWidth - layoutWidth);\n const blendRange = layoutWidth * 0.3;\n const blend = Math.min(1, overflow / blendRange);\n\n let tx = txCenter + (txMouse - txCenter) * blend;\n\n const safeHeight = containerRectHeight - currentGap * 2;\n if (finalHeight > safeHeight) {\n const currentTop = initialElementTop + ty;\n const maxTop = currentGap;\n const minTop = containerRectHeight - currentGap - finalHeight;\n const constrainedTop = clamp(currentTop, minTop, maxTop);\n ty = constrainedTop - initialElementTop;\n }\n\n const safeWidth = containerRectWidth - currentGap * 2;\n if (finalWidth > safeWidth) {\n const currentLeft = initialElementLeft + tx;\n const maxLeft = currentGap;\n const minLeft = containerRectWidth - currentGap - finalWidth;\n const constrainedLeft = clamp(currentLeft, minLeft, maxLeft);\n tx = constrainedLeft - initialElementLeft;\n }\n\n return { tx, ty, blend, finalWidth };\n };\n\n const updateTransform = (scale: number) => {\n currentScale = scale;\n const { tx, ty } = calculateTransform(scale);\n element.style.transformOrigin = '0 0';\n element.style.transform = `translate(${tx}px, ${ty}px) scale(${scale})`;\n };\n\n const resetTransform = () => {\n element.style.transform = 'none';\n element.style.transformOrigin = '0 0';\n currentScale = 1;\n };\n\n const commitZoom = () => {\n const { tx, finalWidth } = calculateTransform(currentScale);\n const delta = (currentScale - 1) * initialZoom;\n\n let anchorX: number;\n let anchorY: number = pointerContainerY;\n\n if (finalWidth <= layoutWidth) {\n anchorX = layoutCenterX;\n } else {\n const scaleDiff = 1 - currentScale;\n anchorX =\n Math.abs(scaleDiff) > 0.001 ? initialElementLeft + tx / scaleDiff : pointerContainerX;\n }\n\n zoomScope.requestZoomBy(delta, { vx: anchorX, vy: anchorY });\n resetTransform();\n initialZoom = 0;\n };\n\n const initializeGestureState = (clientX: number, clientY: number) => {\n const containerRect = container.getBoundingClientRect();\n const innerRect = element.getBoundingClientRect();\n\n currentGap = viewportGap;\n initialElementWidth = innerRect.width;\n initialElementHeight = innerRect.height;\n initialElementLeft = innerRect.left - containerRect.left;\n initialElementTop = innerRect.top - containerRect.top;\n\n containerRectWidth = containerRect.width;\n containerRectHeight = containerRect.height;\n\n // Layout dimensions from container's client area\n layoutWidth = container.clientWidth;\n layoutCenterX = container.clientLeft + layoutWidth / 2;\n\n const rawPointerLocalX = clientX - innerRect.left;\n pointerLocalY = clientY - innerRect.top;\n pointerContainerX = clientX - containerRect.left;\n pointerContainerY = clientY - containerRect.top;\n\n if (initialElementWidth < layoutWidth) {\n pivotLocalX = (pointerContainerX * initialElementWidth) / layoutWidth;\n } else {\n pivotLocalX = rawPointerLocalX;\n }\n };\n\n // --- Handlers ---\n const handleTouchStart = (e: TouchEvent) => {\n if (e.touches.length !== 2) return;\n isPinching = true;\n initialZoom = getState().currentZoomLevel;\n initialDistance = getTouchDistance(e.touches);\n const center = getTouchCenter(e.touches);\n initializeGestureState(center.x, center.y);\n e.preventDefault();\n };\n\n const handleTouchMove = (e: TouchEvent) => {\n if (!isPinching || e.touches.length !== 2) return;\n const currentDistance = getTouchDistance(e.touches);\n const scale = currentDistance / initialDistance;\n updateTransform(scale);\n e.preventDefault();\n };\n\n const handleTouchEnd = (e: TouchEvent) => {\n if (!isPinching) return;\n if (e.touches.length >= 2) return;\n isPinching = false;\n commitZoom();\n };\n\n const handleWheel = (e: WheelEvent) => {\n if (!e.ctrlKey && !e.metaKey) return;\n e.preventDefault();\n\n if (wheelZoomTimeout === null) {\n initialZoom = getState().currentZoomLevel;\n accumulatedWheelScale = 1;\n initializeGestureState(e.clientX, e.clientY);\n } else {\n clearTimeout(wheelZoomTimeout);\n }\n\n const zoomFactor = 1 - e.deltaY * 0.01;\n accumulatedWheelScale *= zoomFactor;\n accumulatedWheelScale = Math.max(0.1, Math.min(10, accumulatedWheelScale));\n updateTransform(accumulatedWheelScale);\n\n wheelZoomTimeout = setTimeout(() => {\n wheelZoomTimeout = null;\n commitZoom();\n accumulatedWheelScale = 1;\n }, 150);\n };\n\n // Subscribe to zoom changes to update margin\n const unsubZoom = zoomScope.onStateChange(() => updateMargin());\n\n // Use ResizeObserver to update margin when element or container size changes\n const resizeObserver = new ResizeObserver(() => updateMargin());\n resizeObserver.observe(element);\n resizeObserver.observe(container);\n\n // Initial margin calculation\n updateMargin();\n\n // Attach events to the viewport container for better UX\n // (gestures work anywhere in viewport, not just on the PDF)\n if (enablePinch) {\n container.addEventListener('touchstart', handleTouchStart, { passive: false });\n container.addEventListener('touchmove', handleTouchMove, { passive: false });\n container.addEventListener('touchend', handleTouchEnd);\n container.addEventListener('touchcancel', handleTouchEnd);\n }\n if (enableWheel) {\n container.addEventListener('wheel', handleWheel, { passive: false });\n }\n\n return () => {\n if (enablePinch) {\n container.removeEventListener('touchstart', handleTouchStart);\n container.removeEventListener('touchmove', handleTouchMove);\n container.removeEventListener('touchend', handleTouchEnd);\n container.removeEventListener('touchcancel', handleTouchEnd);\n }\n if (enableWheel) {\n container.removeEventListener('wheel', handleWheel);\n }\n if (wheelZoomTimeout) {\n clearTimeout(wheelZoomTimeout);\n }\n unsubZoom();\n resizeObserver.disconnect();\n resetTransform();\n element.style.marginLeft = '';\n };\n}\n","import { useLayoutEffect, useRef } from '@framework';\nimport { useCapability } from '@embedpdf/core/@framework';\nimport { ViewportPlugin, useViewportElement } from '@embedpdf/plugin-viewport/@framework';\nimport { setupZoomGestures, ZoomGestureOptions } from '../utils/zoom-gesture-logic';\nimport { useZoomCapability } from './use-zoom';\n\nexport type { ZoomGestureOptions };\n\nexport function useZoomGesture(documentId: string, options: ZoomGestureOptions = {}) {\n const { provides: viewportProvides } = useCapability<ViewportPlugin>('viewport');\n const { provides: zoomProvides } = useZoomCapability();\n const viewportElementRef = useViewportElement();\n const elementRef = useRef<HTMLDivElement>(null);\n\n // Use useLayoutEffect to set up zoom gestures synchronously before paint\n // This prevents flashing and layout jumps that occur with useEffect\n useLayoutEffect(() => {\n const element = elementRef.current;\n const container = viewportElementRef?.current;\n\n if (!element || !container || !zoomProvides) {\n return;\n }\n\n return setupZoomGestures({\n element,\n container,\n documentId,\n zoomProvides,\n viewportGap: viewportProvides?.getViewportGap() || 0,\n options,\n });\n }, [\n viewportProvides,\n zoomProvides,\n documentId,\n viewportElementRef,\n options.enablePinch,\n options.enableWheel,\n ]);\n\n return { elementRef };\n}\n","import { ReactNode, HTMLAttributes, CSSProperties, useMemo } from '@framework';\nimport { useZoomGesture, ZoomGestureOptions } from '../hooks';\n\ntype ZoomGestureWrapperProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ReactNode;\n documentId: string;\n style?: CSSProperties;\n /** Enable pinch-to-zoom gesture (default: true) */\n enablePinch?: boolean;\n /** Enable wheel zoom with ctrl/cmd key (default: true) */\n enableWheel?: boolean;\n};\n\nexport function ZoomGestureWrapper({\n children,\n documentId,\n style,\n enablePinch = true,\n enableWheel = true,\n ...props\n}: ZoomGestureWrapperProps) {\n const options = useMemo<ZoomGestureOptions>(\n () => ({ enablePinch, enableWheel }),\n [enablePinch, enableWheel],\n );\n const { elementRef } = useZoomGesture(documentId, options);\n\n return (\n <div\n ref={elementRef}\n {...props}\n style={{\n ...style,\n display: 'inline-block',\n overflow: 'visible',\n boxSizing: 'border-box',\n }}\n >\n {children}\n </div>\n );\n}\n","import { useEffect, useMemo, useState } from '@framework';\nimport { Rect } from '@embedpdf/models';\nimport { useZoomCapability } from '../hooks/use-zoom';\nimport { useDocumentState } from '@embedpdf/core/@framework';\n\ninterface MarqueeZoomProps {\n documentId: string;\n pageIndex: number;\n scale?: number;\n className?: string;\n stroke?: string;\n fill?: string;\n}\n\nexport const MarqueeZoom = ({\n documentId,\n pageIndex,\n scale: scaleOverride,\n className,\n stroke = 'rgba(33,150,243,0.8)',\n fill = 'rgba(33,150,243,0.15)',\n}: MarqueeZoomProps) => {\n const { provides: zoomPlugin } = useZoomCapability();\n const documentState = useDocumentState(documentId);\n const [rect, setRect] = useState<Rect | null>(null);\n\n const actualScale = useMemo(() => {\n if (scaleOverride !== undefined) return scaleOverride;\n return documentState?.scale ?? 1;\n }, [scaleOverride, documentState?.scale]);\n\n useEffect(() => {\n if (!zoomPlugin) return;\n return zoomPlugin.registerMarqueeOnPage({\n documentId,\n pageIndex,\n scale: actualScale,\n callback: {\n onPreview: setRect,\n },\n });\n }, [zoomPlugin, documentId, pageIndex, actualScale]);\n\n if (!rect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n pointerEvents: 'none',\n left: rect.origin.x * actualScale,\n top: rect.origin.y * actualScale,\n width: rect.size.width * actualScale,\n height: rect.size.height * actualScale,\n border: `1px solid ${stroke}`,\n background: fill,\n boxSizing: 'border-box',\n }}\n className={className}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;AAIO,MAAM,oBAAoB,MAAM,cAA0B,WAAW,EAAE;AACvE,MAAM,gBAAgB,MAAM,UAAsB,WAAW,EAAE;AAM/D,MAAM,UAAU,CAAC,eAAuB;AAC7C,QAAM,EAAE,SAAA,IAAa,kBAAA;AACrB,QAAM,CAAC,OAAO,QAAQ,IAAI,SAA4B,oBAAoB;AAE1E,YAAU,MAAM;AACd,QAAI,CAAC,SAAU;AAEf,UAAM,QAAQ,SAAS,YAAY,UAAU;AAG7C,aAAS,MAAM,UAAU;AAGzB,WAAO,MAAM,cAAc,CAAC,aAAa;AACvC,eAAS,QAAQ;AAAA,IACnB,CAAC;AAAA,EACH,GAAG,CAAC,UAAU,UAAU,CAAC;AAEzB,SAAO;AAAA,IACL;AAAA,IACA,WAAU,qCAAU,YAAY,gBAAe;AAAA,EAAA;AAEnD;ACbA,SAAS,iBAAiB,SAA4B;AACpD,QAAM,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC;AACxC,QAA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export * from '@embedpdf/plugin-viewport/react';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './zoom-gesture-wrapper';
|
|
2
2
|
export * from './marquee-zoom';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
|
|
2
|
+
type ZoomGestureWrapperProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
documentId: string;
|
|
5
|
+
style?: CSSProperties;
|
|
6
|
+
/** Enable pinch-to-zoom gesture (default: true) */
|
|
7
|
+
enablePinch?: boolean;
|
|
8
|
+
/** Enable wheel zoom with ctrl/cmd key (default: true) */
|
|
9
|
+
enableWheel?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function ZoomGestureWrapper({ children, documentId, style, enablePinch, enableWheel, ...props }: ZoomGestureWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './use-zoom';
|
|
2
|
-
export * from './use-
|
|
2
|
+
export * from './use-zoom-gesture';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { ZoomGestureOptions } from '../utils/pinch-zoom-logic';
|
|
2
|
+
export type { ZoomGestureOptions };
|
|
3
|
+
export declare function useZoomGesture(documentId: string, options?: ZoomGestureOptions): {
|
|
2
4
|
elementRef: import('react').RefObject<HTMLDivElement>;
|
|
3
5
|
};
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { ViewportCapability } from '@embedpdf/plugin-viewport';
|
|
2
2
|
import { ZoomCapability } from '../../index.ts';
|
|
3
|
-
export interface
|
|
3
|
+
export interface ZoomGestureOptions {
|
|
4
|
+
/** Enable pinch-to-zoom gesture (default: true) */
|
|
5
|
+
enablePinch?: boolean;
|
|
6
|
+
/** Enable wheel zoom with ctrl/cmd key (default: true) */
|
|
7
|
+
enableWheel?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ZoomGestureDeps {
|
|
4
10
|
element: HTMLDivElement;
|
|
11
|
+
/** Optional viewport container element for attaching events (from context) */
|
|
12
|
+
container?: HTMLElement;
|
|
5
13
|
documentId: string;
|
|
6
14
|
viewportProvides: ViewportCapability;
|
|
7
15
|
zoomProvides: ZoomCapability;
|
|
16
|
+
options?: ZoomGestureOptions;
|
|
8
17
|
}
|
|
9
|
-
export declare function
|
|
18
|
+
export declare function setupZoomGestures({ element, container, documentId, viewportProvides, zoomProvides, options, }: ZoomGestureDeps): () => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ZoomCapability } from '../../index.ts';
|
|
2
|
+
export interface ZoomGestureOptions {
|
|
3
|
+
/** Enable pinch-to-zoom gesture (default: true) */
|
|
4
|
+
enablePinch?: boolean;
|
|
5
|
+
/** Enable wheel zoom with ctrl/cmd key (default: true) */
|
|
6
|
+
enableWheel?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ZoomGestureDeps {
|
|
9
|
+
element: HTMLDivElement;
|
|
10
|
+
/** Viewport container element for attaching events */
|
|
11
|
+
container: HTMLElement;
|
|
12
|
+
documentId: string;
|
|
13
|
+
zoomProvides: ZoomCapability;
|
|
14
|
+
/** Viewport gap in pixels (default: 0) */
|
|
15
|
+
viewportGap?: number;
|
|
16
|
+
options?: ZoomGestureOptions;
|
|
17
|
+
}
|
|
18
|
+
export declare function setupZoomGestures({ element, container, documentId, zoomProvides, viewportGap, options, }: ZoomGestureDeps): () => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './zoom-gesture-wrapper';
|
|
2
2
|
export * from './marquee-zoom';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes, CSSProperties } from '../../preact/adapter.ts';
|
|
2
|
+
type ZoomGestureWrapperProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
documentId: string;
|
|
5
|
+
style?: CSSProperties;
|
|
6
|
+
/** Enable pinch-to-zoom gesture (default: true) */
|
|
7
|
+
enablePinch?: boolean;
|
|
8
|
+
/** Enable wheel zoom with ctrl/cmd key (default: true) */
|
|
9
|
+
enableWheel?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function ZoomGestureWrapper({ children, documentId, style, enablePinch, enableWheel, ...props }: ZoomGestureWrapperProps): import("preact").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './use-zoom';
|
|
2
|
-
export * from './use-
|
|
2
|
+
export * from './use-zoom-gesture';
|