@embedpdf/plugin-zoom 1.0.11 → 1.0.12
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/hammer-Bs-QCG8V.cjs +7 -0
- package/dist/hammer-Bs-QCG8V.cjs.map +1 -0
- package/dist/hammer-e1aXHboh.js +1810 -0
- package/dist/hammer-e1aXHboh.js.map +1 -0
- package/dist/index.cjs +2 -481
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -147
- package/dist/index.js +43 -59
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +20 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/manifest.d.ts +4 -0
- package/dist/lib/reducer.d.ts +5 -0
- package/dist/lib/types.d.ts +84 -0
- package/dist/lib/zoom-plugin.d.ts +38 -0
- package/dist/preact/adapter.d.ts +5 -0
- package/dist/preact/core.d.ts +1 -0
- package/dist/preact/index.cjs +2 -262
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.d.ts +1 -54
- package/dist/preact/index.js +29 -34
- package/dist/preact/index.js.map +1 -1
- package/dist/preact/interaction-manager.d.ts +1 -0
- package/dist/react/adapter.d.ts +2 -0
- package/dist/react/core.d.ts +1 -0
- package/dist/react/index.cjs +2 -262
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +1 -53
- package/dist/react/index.js +28 -34
- package/dist/react/index.js.map +1 -1
- package/dist/react/interaction-manager.d.ts +1 -0
- package/dist/shared-preact/components/index.d.ts +2 -0
- package/dist/shared-preact/components/marquee-zoom.d.ts +21 -0
- package/dist/shared-preact/components/pinch-wrapper.d.ts +7 -0
- package/dist/shared-preact/hooks/index.d.ts +2 -0
- package/dist/shared-preact/hooks/use-pinch-zoom.d.ts +3 -0
- package/dist/shared-preact/hooks/use-zoom.d.ts +15 -0
- package/dist/shared-preact/index.d.ts +2 -0
- package/dist/shared-react/components/index.d.ts +2 -0
- package/dist/shared-react/components/marquee-zoom.d.ts +21 -0
- package/dist/shared-react/components/pinch-wrapper.d.ts +7 -0
- package/dist/shared-react/hooks/index.d.ts +2 -0
- package/dist/shared-react/hooks/use-pinch-zoom.d.ts +3 -0
- package/dist/shared-react/hooks/use-zoom.d.ts +15 -0
- package/dist/shared-react/index.d.ts +2 -0
- package/package.json +18 -17
- package/dist/index.d.cts +0 -147
- package/dist/preact/index.d.cts +0 -54
- package/dist/react/index.d.cts +0 -53
package/dist/react/index.d.ts
CHANGED
|
@@ -1,53 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { ZoomPlugin, ZoomState } from '@embedpdf/plugin-zoom';
|
|
3
|
-
import * as react from 'react';
|
|
4
|
-
import { ReactNode } from 'react';
|
|
5
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
-
|
|
7
|
-
declare const useZoomCapability: () => {
|
|
8
|
-
provides: Readonly<_embedpdf_plugin_zoom.ZoomCapability> | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
ready: Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
declare const useZoomPlugin: () => {
|
|
13
|
-
plugin: ZoomPlugin | null;
|
|
14
|
-
isLoading: boolean;
|
|
15
|
-
ready: Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
declare const useZoom: () => {
|
|
18
|
-
state: ZoomState;
|
|
19
|
-
provides: Readonly<_embedpdf_plugin_zoom.ZoomCapability> | null;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
declare function usePinch(): {
|
|
23
|
-
elementRef: react.RefObject<HTMLDivElement>;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
type PinchWrapperProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
27
|
-
children: ReactNode;
|
|
28
|
-
style?: React.CSSProperties;
|
|
29
|
-
};
|
|
30
|
-
declare function PinchWrapper({ children, style, ...props }: PinchWrapperProps): react_jsx_runtime.JSX.Element;
|
|
31
|
-
|
|
32
|
-
interface MarqueeZoomProps {
|
|
33
|
-
/** Index of the page this layer lives on */
|
|
34
|
-
pageIndex: number;
|
|
35
|
-
/** Scale of the page */
|
|
36
|
-
scale: number;
|
|
37
|
-
/** Width of the page */
|
|
38
|
-
pageWidth: number;
|
|
39
|
-
/** Height of the page */
|
|
40
|
-
pageHeight: number;
|
|
41
|
-
/** Optional CSS class applied to the marquee rectangle */
|
|
42
|
-
className?: string;
|
|
43
|
-
/** Stroke / fill colours (defaults below) */
|
|
44
|
-
stroke?: string;
|
|
45
|
-
fill?: string;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Draws a marquee rectangle while the user drags.
|
|
49
|
-
* Hook it into the interaction-manager with modeId = 'marqueeZoom'.
|
|
50
|
-
*/
|
|
51
|
-
declare const MarqueeZoom: ({ pageIndex, scale, pageWidth, pageHeight, className, stroke, fill, }: MarqueeZoomProps) => react_jsx_runtime.JSX.Element | null;
|
|
52
|
-
|
|
53
|
-
export { MarqueeZoom, PinchWrapper, usePinch, useZoom, useZoomCapability, useZoomPlugin };
|
|
1
|
+
export * from '../shared-react';
|
package/dist/react/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
// src/react/hooks/use-zoom.ts
|
|
2
1
|
import { useCapability, usePlugin } from "@embedpdf/core/react";
|
|
3
|
-
import {
|
|
4
|
-
import { useEffect,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { ZoomPlugin, initialState } from "@embedpdf/plugin-zoom";
|
|
3
|
+
import { useState, useEffect, useRef, useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/react";
|
|
6
|
+
const useZoomCapability = () => useCapability(ZoomPlugin.id);
|
|
7
|
+
const useZoomPlugin = () => usePlugin(ZoomPlugin.id);
|
|
8
|
+
const useZoom = () => {
|
|
8
9
|
const { provides } = useZoomCapability();
|
|
9
10
|
const [state, setState] = useState(initialState);
|
|
10
11
|
useEffect(() => {
|
|
11
|
-
return provides
|
|
12
|
+
return provides == null ? void 0 : provides.onStateChange((action) => {
|
|
12
13
|
setState(action);
|
|
13
14
|
});
|
|
14
15
|
}, [provides]);
|
|
@@ -17,15 +18,11 @@ var useZoom = () => {
|
|
|
17
18
|
provides
|
|
18
19
|
};
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
-
// src/react/hooks/use-pinch-zoom.ts
|
|
22
|
-
import { useEffect as useEffect2, useRef } from "react";
|
|
23
|
-
import { useCapability as useCapability2 } from "@embedpdf/core/react";
|
|
24
21
|
function usePinch() {
|
|
25
|
-
const { provides: viewportProvides } =
|
|
22
|
+
const { provides: viewportProvides } = useCapability("viewport");
|
|
26
23
|
const { provides: zoomProvides } = useZoomCapability();
|
|
27
24
|
const elementRef = useRef(null);
|
|
28
|
-
|
|
25
|
+
useEffect(() => {
|
|
29
26
|
const element = elementRef.current;
|
|
30
27
|
if (!element || !viewportProvides || !zoomProvides) {
|
|
31
28
|
return;
|
|
@@ -45,6 +42,7 @@ function usePinch() {
|
|
|
45
42
|
element.style.transformOrigin = "0 0";
|
|
46
43
|
};
|
|
47
44
|
const pinchStart = (e) => {
|
|
45
|
+
var _a;
|
|
48
46
|
initialZoom = getState().currentZoomLevel;
|
|
49
47
|
const contRect = viewportProvides.getBoundingRect();
|
|
50
48
|
lastCenter = {
|
|
@@ -53,14 +51,15 @@ function usePinch() {
|
|
|
53
51
|
};
|
|
54
52
|
const innerRect = element.getBoundingClientRect();
|
|
55
53
|
element.style.transformOrigin = `${e.center.x - innerRect.left}px ${e.center.y - innerRect.top}px`;
|
|
56
|
-
if (e.srcEvent
|
|
54
|
+
if ((_a = e.srcEvent) == null ? void 0 : _a.cancelable) {
|
|
57
55
|
e.srcEvent.preventDefault();
|
|
58
56
|
e.srcEvent.stopPropagation();
|
|
59
57
|
}
|
|
60
58
|
};
|
|
61
59
|
const pinchMove = (e) => {
|
|
60
|
+
var _a;
|
|
62
61
|
updateTransform(e.scale);
|
|
63
|
-
if (e.srcEvent
|
|
62
|
+
if ((_a = e.srcEvent) == null ? void 0 : _a.cancelable) {
|
|
64
63
|
e.srcEvent.preventDefault();
|
|
65
64
|
e.srcEvent.stopPropagation();
|
|
66
65
|
}
|
|
@@ -73,7 +72,7 @@ function usePinch() {
|
|
|
73
72
|
};
|
|
74
73
|
const setupHammer = async () => {
|
|
75
74
|
try {
|
|
76
|
-
const Hammer = (await import("
|
|
75
|
+
const Hammer = (await import("../hammer-e1aXHboh.js").then((n) => n.h)).default;
|
|
77
76
|
const inputClass = (() => {
|
|
78
77
|
const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
79
78
|
const SUPPORT_TOUCH = "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
@@ -97,15 +96,12 @@ function usePinch() {
|
|
|
97
96
|
};
|
|
98
97
|
setupHammer();
|
|
99
98
|
return () => {
|
|
100
|
-
hammer
|
|
99
|
+
hammer == null ? void 0 : hammer.destroy();
|
|
101
100
|
resetTransform();
|
|
102
101
|
};
|
|
103
102
|
}, [viewportProvides, zoomProvides]);
|
|
104
103
|
return { elementRef };
|
|
105
104
|
}
|
|
106
|
-
|
|
107
|
-
// src/react/components/pinch-wrapper.tsx
|
|
108
|
-
import { jsx } from "react/jsx-runtime";
|
|
109
105
|
function PinchWrapper({ children, style, ...props }) {
|
|
110
106
|
const { elementRef } = usePinch();
|
|
111
107
|
return /* @__PURE__ */ jsx(
|
|
@@ -125,12 +121,7 @@ function PinchWrapper({ children, style, ...props }) {
|
|
|
125
121
|
}
|
|
126
122
|
);
|
|
127
123
|
}
|
|
128
|
-
|
|
129
|
-
// src/react/components/marquee-zoom.tsx
|
|
130
|
-
import { useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState2 } from "react";
|
|
131
|
-
import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/react";
|
|
132
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
133
|
-
var MarqueeZoom = ({
|
|
124
|
+
const MarqueeZoom = ({
|
|
134
125
|
pageIndex,
|
|
135
126
|
scale,
|
|
136
127
|
pageWidth,
|
|
@@ -142,16 +133,17 @@ var MarqueeZoom = ({
|
|
|
142
133
|
const { provides: zoom } = useZoomCapability();
|
|
143
134
|
const { register } = usePointerHandlers({ modeId: "marqueeZoom", pageIndex });
|
|
144
135
|
const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
|
|
145
|
-
const startRef =
|
|
146
|
-
const [rect, setRect] =
|
|
136
|
+
const startRef = useRef(null);
|
|
137
|
+
const [rect, setRect] = useState(null);
|
|
147
138
|
const pageWidthPDF = pageWidth / scale;
|
|
148
139
|
const pageHeightPDF = pageHeight / scale;
|
|
149
140
|
const handlers = useMemo(
|
|
150
141
|
() => ({
|
|
151
142
|
onPointerDown: (pos, evt) => {
|
|
143
|
+
var _a, _b;
|
|
152
144
|
startRef.current = pos;
|
|
153
145
|
setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });
|
|
154
|
-
evt.target
|
|
146
|
+
(_b = (_a = evt.target) == null ? void 0 : _a.setPointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
|
|
155
147
|
},
|
|
156
148
|
onPointerMove: (pos) => {
|
|
157
149
|
if (!startRef.current) return;
|
|
@@ -165,6 +157,7 @@ var MarqueeZoom = ({
|
|
|
165
157
|
setRect({ origin: { x: left, y: top }, size: { width, height } });
|
|
166
158
|
},
|
|
167
159
|
onPointerUp: (_, evt) => {
|
|
160
|
+
var _a, _b;
|
|
168
161
|
if (rect && zoom) {
|
|
169
162
|
const dragPx = Math.max(rect.size.width, rect.size.height) * scale;
|
|
170
163
|
if (dragPx > 5) {
|
|
@@ -175,22 +168,23 @@ var MarqueeZoom = ({
|
|
|
175
168
|
}
|
|
176
169
|
startRef.current = null;
|
|
177
170
|
setRect(null);
|
|
178
|
-
evt.target
|
|
171
|
+
(_b = (_a = evt.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
|
|
179
172
|
},
|
|
180
173
|
onPointerCancel: (_, evt) => {
|
|
174
|
+
var _a, _b;
|
|
181
175
|
startRef.current = null;
|
|
182
176
|
setRect(null);
|
|
183
|
-
evt.target
|
|
177
|
+
(_b = (_a = evt.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
|
|
184
178
|
}
|
|
185
179
|
}),
|
|
186
180
|
[pageWidthPDF, pageWidthPDF, zoom, scale, rect, pageIndex]
|
|
187
181
|
);
|
|
188
|
-
|
|
182
|
+
useEffect(() => {
|
|
189
183
|
if (!register) return;
|
|
190
184
|
return register(handlers);
|
|
191
185
|
}, [register, handlers]);
|
|
192
186
|
if (!rect) return null;
|
|
193
|
-
return /* @__PURE__ */
|
|
187
|
+
return /* @__PURE__ */ jsx(
|
|
194
188
|
"div",
|
|
195
189
|
{
|
|
196
190
|
style: {
|
|
@@ -217,4 +211,4 @@ export {
|
|
|
217
211
|
useZoomCapability,
|
|
218
212
|
useZoomPlugin
|
|
219
213
|
};
|
|
220
|
-
//# sourceMappingURL=index.js.map
|
|
214
|
+
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/hooks/use-zoom.ts","../../src/react/hooks/use-pinch-zoom.ts","../../src/react/components/pinch-wrapper.tsx","../../src/react/components/marquee-zoom.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { initialState, ZoomPlugin, ZoomState } from '@embedpdf/plugin-zoom';\nimport { useEffect, useState } from 'react';\n\nexport const useZoomCapability = () => useCapability<ZoomPlugin>(ZoomPlugin.id);\nexport const useZoomPlugin = () => usePlugin<ZoomPlugin>(ZoomPlugin.id);\n\nexport const useZoom = () => {\n const { provides } = useZoomCapability();\n const [state, setState] = useState<ZoomState>(initialState);\n\n useEffect(() => {\n return provides?.onStateChange((action) => {\n setState(action);\n });\n }, [provides]);\n\n return {\n state,\n provides,\n };\n};\n","import { useEffect, useRef } from 'react';\nimport { useCapability } from '@embedpdf/core/react';\nimport { ViewportPlugin } from '@embedpdf/plugin-viewport';\nimport { ZoomState } from '@embedpdf/plugin-zoom';\n\nimport { useZoomCapability } from './use-zoom';\n\nexport function usePinch() {\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 // Check if we're on the client side\n if (typeof window === 'undefined') {\n return;\n }\n\n let hammer: any | undefined;\n let initialZoom = 0; // numeric scale at pinchstart\n let lastCenter = { x: 0, y: 0 };\n\n const getState = (): ZoomState => zoomProvides.getState();\n\n const updateTransform = (scale: number) => {\n // 1 → no scale; we only scale *relatively* to the start\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 = viewportProvides.getBoundingRect();\n\n lastCenter = {\n x: e.center.x - contRect.origin.x,\n y: e.center.y - contRect.origin.y,\n };\n\n // put the transform-origin under the fingers so the preview feels right\n const innerRect = element.getBoundingClientRect();\n element.style.transformOrigin = `${e.center.x - innerRect.left}px ${e.center.y - innerRect.top}px`;\n\n // stop the browser’s own pinch-zoom\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); // *only* CSS, no real zoom yet\n if (e.srcEvent?.cancelable) {\n e.srcEvent.preventDefault();\n e.srcEvent.stopPropagation();\n }\n };\n\n const pinchEnd = (e: HammerInput) => {\n // translate the relative hammer scale into a delta for requestZoomBy\n const delta = (e.scale - 1) * initialZoom;\n zoomProvides.requestZoomBy(delta, { vx: lastCenter.x, vy: lastCenter.y });\n\n resetTransform();\n initialZoom = 0;\n };\n\n // Dynamically import and setup Hammer\n const setupHammer = async () => {\n try {\n const Hammer = (await import('hammerjs')).default;\n\n /* ------------------------------------------------------------------ */\n /* Hammer setup */\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', // allow scroll in every direction\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 }, [viewportProvides, zoomProvides]);\n\n return { elementRef };\n}\n","import { ReactNode } from 'react';\n\nimport { usePinch } from '../hooks';\n\ntype PinchWrapperProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ReactNode;\n style?: React.CSSProperties;\n};\n\nexport function PinchWrapper({ children, style, ...props }: PinchWrapperProps) {\n const { elementRef } = usePinch();\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, useRef, useState } from 'react';\nimport type { PointerEventHandlers } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/react';\nimport { Rect } from '@embedpdf/models';\n\nimport { useZoomCapability } from '../hooks/use-zoom';\n\ninterface MarqueeZoomProps {\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale: number;\n /** Width of the page */\n pageWidth: number;\n /** Height of the page */\n pageHeight: number;\n /** Optional CSS class applied to the marquee rectangle */\n className?: string;\n /** Stroke / fill colours (defaults below) */\n stroke?: string;\n fill?: string;\n}\n\n/**\n * Draws a marquee rectangle while the user drags.\n * Hook it into the interaction-manager with modeId = 'marqueeZoom'.\n */\nexport const MarqueeZoom = ({\n pageIndex,\n scale,\n pageWidth,\n pageHeight,\n className,\n stroke = 'rgba(33,150,243,0.8)',\n fill = 'rgba(33,150,243,0.15)',\n}: MarqueeZoomProps) => {\n /* ------------------------------------------------------------------ */\n /* zoom capability */\n /* ------------------------------------------------------------------ */\n const { provides: zoom } = useZoomCapability();\n\n /* ------------------------------------------------------------------ */\n /* integration with interaction-manager */\n /* ------------------------------------------------------------------ */\n const { register } = usePointerHandlers({ modeId: 'marqueeZoom', pageIndex });\n\n /* ------------------------------------------------------------------ */\n /* helpers */\n /* ------------------------------------------------------------------ */\n const clamp = (v: number, min: number, max: number) => Math.max(min, Math.min(max, v));\n\n /* ------------------------------------------------------------------ */\n /* local state – start / current drag position */\n /* ------------------------------------------------------------------ */\n const startRef = useRef<{ x: number; y: number } | null>(null);\n const [rect, setRect] = useState<Rect | null>(null);\n\n /* page size in **PDF-space** (unscaled) ----------------------------- */\n const pageWidthPDF = pageWidth / scale;\n const pageHeightPDF = pageHeight / scale;\n\n /* ------------------------------------------------------------------ */\n /* pointer handlers */\n /* ------------------------------------------------------------------ */\n const handlers = useMemo<PointerEventHandlers<PointerEvent>>(\n () => ({\n onPointerDown: (pos, evt) => {\n startRef.current = pos;\n setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });\n (evt.target as HTMLElement)?.setPointerCapture?.(evt.pointerId);\n },\n onPointerMove: (pos) => {\n if (!startRef.current) return;\n /* clamp current position to the page bounds */\n const curX = clamp(pos.x, 0, pageWidthPDF);\n const curY = clamp(pos.y, 0, pageHeightPDF);\n\n const { x: sx, y: sy } = startRef.current;\n const left = Math.min(sx, curX);\n const top = Math.min(sy, curY);\n const width = Math.abs(curX - sx);\n const height = Math.abs(curY - sy);\n\n setRect({ origin: { x: left, y: top }, size: { width, height } });\n },\n onPointerUp: (_, evt) => {\n if (rect && zoom) {\n const dragPx = Math.max(rect.size.width, rect.size.height) * scale;\n if (dragPx > 5) {\n // real drag → zoom to it\n zoom.zoomToArea(pageIndex, rect);\n } else {\n // tiny drag → simple zoom-in\n zoom.zoomIn();\n }\n }\n\n startRef.current = null;\n setRect(null);\n (evt.target as HTMLElement)?.releasePointerCapture?.(evt.pointerId);\n },\n onPointerCancel: (_, evt) => {\n startRef.current = null;\n setRect(null);\n (evt.target as HTMLElement)?.releasePointerCapture?.(evt.pointerId);\n },\n }),\n [pageWidthPDF, pageWidthPDF, zoom, scale, rect, pageIndex],\n );\n\n /* register with the interaction-manager */\n useEffect(() => {\n if (!register) return;\n return register(handlers);\n }, [register, handlers]);\n\n /* ------------------------------------------------------------------ */\n /* render */\n /* ------------------------------------------------------------------ */\n if (!rect) return null; // nothing to draw\n\n return (\n <div\n /* Each page wrapper is position:relative, so absolute is fine */\n style={{\n position: 'absolute',\n pointerEvents: 'none', // ignore hits – underlying page still gets events\n left: rect.origin.x * scale,\n top: rect.origin.y * scale,\n width: rect.size.width * scale,\n height: rect.size.height * scale,\n border: `1px solid ${stroke}`,\n background: fill,\n boxSizing: 'border-box',\n }}\n className={className}\n />\n );\n};\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,cAAc,kBAA6B;AACpD,SAAS,WAAW,gBAAgB;AAE7B,IAAM,oBAAoB,MAAM,cAA0B,WAAW,EAAE;AACvE,IAAM,gBAAgB,MAAM,UAAsB,WAAW,EAAE;AAE/D,IAAM,UAAU,MAAM;AAC3B,QAAM,EAAE,SAAS,IAAI,kB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QAAO;AAElB,SACE,gBAAAH;AAAA,IAAC;AAAA;AAAA,MAEC,OAAO;AAAA,QACL,UAAU;AAAA,QACV,eAAe;AAAA;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,MACb;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;","names":["useEffect","useCapability","useCapability","useEffect","useEffect","useRef","useState","jsx","useRef","useState","useEffect"]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-zoom.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 { initialState, ZoomPlugin, ZoomState } 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\nexport const useZoom = () => {\n const { provides } = useZoomCapability();\n const [state, setState] = useState<ZoomState>(initialState);\n\n useEffect(() => {\n return provides?.onStateChange((action) => {\n setState(action);\n });\n }, [provides]);\n\n return {\n state,\n provides,\n };\n};\n","import { useEffect, useRef } from '@framework';\nimport { useCapability } from '@embedpdf/core/@framework';\nimport { ViewportPlugin } from '@embedpdf/plugin-viewport';\nimport { ZoomState } from '@embedpdf/plugin-zoom';\n\nimport { useZoomCapability } from './use-zoom';\n\nexport function usePinch() {\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 // Check if we're on the client side\n if (typeof window === 'undefined') {\n return;\n }\n\n let hammer: any | undefined;\n let initialZoom = 0; // numeric scale at pinchstart\n let lastCenter = { x: 0, y: 0 };\n\n const getState = (): ZoomState => zoomProvides.getState();\n\n const updateTransform = (scale: number) => {\n // 1 → no scale; we only scale *relatively* to the start\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 = viewportProvides.getBoundingRect();\n\n lastCenter = {\n x: e.center.x - contRect.origin.x,\n y: e.center.y - contRect.origin.y,\n };\n\n // put the transform-origin under the fingers so the preview feels right\n const innerRect = element.getBoundingClientRect();\n element.style.transformOrigin = `${e.center.x - innerRect.left}px ${e.center.y - innerRect.top}px`;\n\n // stop the browser’s own pinch-zoom\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); // *only* CSS, no real zoom yet\n if (e.srcEvent?.cancelable) {\n e.srcEvent.preventDefault();\n e.srcEvent.stopPropagation();\n }\n };\n\n const pinchEnd = (e: HammerInput) => {\n // translate the relative hammer scale into a delta for requestZoomBy\n const delta = (e.scale - 1) * initialZoom;\n zoomProvides.requestZoomBy(delta, { vx: lastCenter.x, vy: lastCenter.y });\n\n resetTransform();\n initialZoom = 0;\n };\n\n // Dynamically import and setup Hammer\n const setupHammer = async () => {\n try {\n const Hammer = (await import('hammerjs')).default;\n\n /* ------------------------------------------------------------------ */\n /* Hammer setup */\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', // allow scroll in every direction\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 }, [viewportProvides, zoomProvides]);\n\n return { elementRef };\n}\n","import { ReactNode, HTMLAttributes, CSSProperties } from '@framework';\n\nimport { usePinch } from '../hooks';\n\ntype PinchWrapperProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ReactNode;\n style?: CSSProperties;\n};\n\nexport function PinchWrapper({ children, style, ...props }: PinchWrapperProps) {\n const { elementRef } = usePinch();\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, useRef, useState } from '@framework';\nimport type { PointerEventHandlers } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/@framework';\nimport { Rect } from '@embedpdf/models';\n\nimport { useZoomCapability } from '../hooks/use-zoom';\n\ninterface MarqueeZoomProps {\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale: number;\n /** Width of the page */\n pageWidth: number;\n /** Height of the page */\n pageHeight: number;\n /** Optional CSS class applied to the marquee rectangle */\n className?: string;\n /** Stroke / fill colours (defaults below) */\n stroke?: string;\n fill?: string;\n}\n\n/**\n * Draws a marquee rectangle while the user drags.\n * Hook it into the interaction-manager with modeId = 'marqueeZoom'.\n */\nexport const MarqueeZoom = ({\n pageIndex,\n scale,\n pageWidth,\n pageHeight,\n className,\n stroke = 'rgba(33,150,243,0.8)',\n fill = 'rgba(33,150,243,0.15)',\n}: MarqueeZoomProps) => {\n /* ------------------------------------------------------------------ */\n /* zoom capability */\n /* ------------------------------------------------------------------ */\n const { provides: zoom } = useZoomCapability();\n\n /* ------------------------------------------------------------------ */\n /* integration with interaction-manager */\n /* ------------------------------------------------------------------ */\n const { register } = usePointerHandlers({ modeId: 'marqueeZoom', pageIndex });\n\n /* ------------------------------------------------------------------ */\n /* helpers */\n /* ------------------------------------------------------------------ */\n const clamp = (v: number, min: number, max: number) => Math.max(min, Math.min(max, v));\n\n /* ------------------------------------------------------------------ */\n /* local state – start / current drag position */\n /* ------------------------------------------------------------------ */\n const startRef = useRef<{ x: number; y: number } | null>(null);\n const [rect, setRect] = useState<Rect | null>(null);\n\n /* page size in **PDF-space** (unscaled) ----------------------------- */\n const pageWidthPDF = pageWidth / scale;\n const pageHeightPDF = pageHeight / scale;\n\n /* ------------------------------------------------------------------ */\n /* pointer handlers */\n /* ------------------------------------------------------------------ */\n const handlers = useMemo<PointerEventHandlers<PointerEvent>>(\n () => ({\n onPointerDown: (pos, evt) => {\n startRef.current = pos;\n setRect({ origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } });\n (evt.target as HTMLElement)?.setPointerCapture?.(evt.pointerId);\n },\n onPointerMove: (pos) => {\n if (!startRef.current) return;\n /* clamp current position to the page bounds */\n const curX = clamp(pos.x, 0, pageWidthPDF);\n const curY = clamp(pos.y, 0, pageHeightPDF);\n\n const { x: sx, y: sy } = startRef.current;\n const left = Math.min(sx, curX);\n const top = Math.min(sy, curY);\n const width = Math.abs(curX - sx);\n const height = Math.abs(curY - sy);\n\n setRect({ origin: { x: left, y: top }, size: { width, height } });\n },\n onPointerUp: (_, evt) => {\n if (rect && zoom) {\n const dragPx = Math.max(rect.size.width, rect.size.height) * scale;\n if (dragPx > 5) {\n // real drag → zoom to it\n zoom.zoomToArea(pageIndex, rect);\n } else {\n // tiny drag → simple zoom-in\n zoom.zoomIn();\n }\n }\n\n startRef.current = null;\n setRect(null);\n (evt.target as HTMLElement)?.releasePointerCapture?.(evt.pointerId);\n },\n onPointerCancel: (_, evt) => {\n startRef.current = null;\n setRect(null);\n (evt.target as HTMLElement)?.releasePointerCapture?.(evt.pointerId);\n },\n }),\n [pageWidthPDF, pageWidthPDF, zoom, scale, rect, pageIndex],\n );\n\n /* register with the interaction-manager */\n useEffect(() => {\n if (!register) return;\n return register(handlers);\n }, [register, handlers]);\n\n /* ------------------------------------------------------------------ */\n /* render */\n /* ------------------------------------------------------------------ */\n if (!rect) return null; // nothing to draw\n\n return (\n <div\n /* Each page wrapper is position:relative, so absolute is fine */\n style={{\n position: 'absolute',\n pointerEvents: 'none', // ignore hits – underlying page still gets events\n left: rect.origin.x * scale,\n top: rect.origin.y * scale,\n width: rect.size.width * scale,\n height: rect.size.height * scale,\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;AAE/D,MAAM,UAAU,MAAM;AACrB,QAAA,EAAE,SAAS,IAAI,kBAAkB;AACvC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAoB,YAAY;AAE1D,YAAU,MAAM;AACP,WAAA,qCAAU,cAAc,CAAC,WAAW;AACzC,eAAS,MAAM;AAAA,IAAA;AAAA,EAChB,GACA,CAAC,QAAQ,CAAC;AAEN,SAAA;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;ACdO,SAAS,WAAW;AACzB,QAAM,EAAE,UAAU,qBAAqB,cAA8B,UAAU;AAC/E,QAAM,EAAE,UAAU,aAAa,IAAI,kBAAkB;AAC/C,QAAA,aAAa,OAAuB,IA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+
/** Scale of the page */
|
|
5
|
+
scale: number;
|
|
6
|
+
/** Width of the page */
|
|
7
|
+
pageWidth: number;
|
|
8
|
+
/** Height of the page */
|
|
9
|
+
pageHeight: number;
|
|
10
|
+
/** Optional CSS class applied to the marquee rectangle */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Stroke / fill colours (defaults below) */
|
|
13
|
+
stroke?: string;
|
|
14
|
+
fill?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Draws a marquee rectangle while the user drags.
|
|
18
|
+
* Hook it into the interaction-manager with modeId = 'marqueeZoom'.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MarqueeZoom: ({ pageIndex, scale, pageWidth, pageHeight, className, stroke, fill, }: MarqueeZoomProps) => import("preact").JSX.Element | null;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes, CSSProperties } from '../../preact/adapter.ts';
|
|
2
|
+
type PinchWrapperProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
};
|
|
6
|
+
export declare function PinchWrapper({ children, style, ...props }: PinchWrapperProps): import("preact").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ZoomPlugin, ZoomState } from '../../lib/index.ts';
|
|
2
|
+
export declare const useZoomCapability: () => {
|
|
3
|
+
provides: Readonly<import('../../lib/index.ts').ZoomCapability> | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useZoomPlugin: () => {
|
|
8
|
+
plugin: ZoomPlugin | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export declare const useZoom: () => {
|
|
13
|
+
state: ZoomState;
|
|
14
|
+
provides: Readonly<import('../../lib/index.ts').ZoomCapability> | null;
|
|
15
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface MarqueeZoomProps {
|
|
2
|
+
/** Index of the page this layer lives on */
|
|
3
|
+
pageIndex: number;
|
|
4
|
+
/** Scale of the page */
|
|
5
|
+
scale: number;
|
|
6
|
+
/** Width of the page */
|
|
7
|
+
pageWidth: number;
|
|
8
|
+
/** Height of the page */
|
|
9
|
+
pageHeight: number;
|
|
10
|
+
/** Optional CSS class applied to the marquee rectangle */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Stroke / fill colours (defaults below) */
|
|
13
|
+
stroke?: string;
|
|
14
|
+
fill?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Draws a marquee rectangle while the user drags.
|
|
18
|
+
* Hook it into the interaction-manager with modeId = 'marqueeZoom'.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MarqueeZoom: ({ pageIndex, scale, pageWidth, pageHeight, className, stroke, fill, }: MarqueeZoomProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
|
|
2
|
+
type PinchWrapperProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
};
|
|
6
|
+
export declare function PinchWrapper({ children, style, ...props }: PinchWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ZoomPlugin, ZoomState } from '../../lib/index.ts';
|
|
2
|
+
export declare const useZoomCapability: () => {
|
|
3
|
+
provides: Readonly<import('../../lib/index.ts').ZoomCapability> | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useZoomPlugin: () => {
|
|
8
|
+
plugin: ZoomPlugin | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export declare const useZoom: () => {
|
|
13
|
+
state: ZoomState;
|
|
14
|
+
provides: Readonly<import('../../lib/index.ts').ZoomCapability> | null;
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-zoom",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -24,26 +24,26 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"hammerjs": "^2.0.8",
|
|
27
|
-
"@embedpdf/models": "1.0.
|
|
27
|
+
"@embedpdf/models": "1.0.12"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/hammerjs": "^2.0.46",
|
|
31
31
|
"@types/react": "^18.2.0",
|
|
32
|
-
"tsup": "^8.0.0",
|
|
33
32
|
"typescript": "^5.0.0",
|
|
34
|
-
"@embedpdf/core": "1.0.
|
|
35
|
-
"@embedpdf/plugin-viewport": "1.0.
|
|
36
|
-
"@embedpdf/
|
|
37
|
-
"@embedpdf/plugin-
|
|
33
|
+
"@embedpdf/core": "1.0.12",
|
|
34
|
+
"@embedpdf/plugin-viewport": "1.0.12",
|
|
35
|
+
"@embedpdf/build": "1.0.0",
|
|
36
|
+
"@embedpdf/plugin-interaction-manager": "1.0.12",
|
|
37
|
+
"@embedpdf/plugin-scroll": "1.0.12"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": ">=16.8.0",
|
|
41
41
|
"react-dom": ">=16.8.0",
|
|
42
42
|
"preact": "^10.26.4",
|
|
43
|
-
"@embedpdf/core": "1.0.
|
|
44
|
-
"@embedpdf/plugin-viewport": "1.0.
|
|
45
|
-
"@embedpdf/plugin-scroll": "1.0.
|
|
46
|
-
"@embedpdf/plugin-interaction-manager": "1.0.
|
|
43
|
+
"@embedpdf/core": "1.0.12",
|
|
44
|
+
"@embedpdf/plugin-viewport": "1.0.12",
|
|
45
|
+
"@embedpdf/plugin-scroll": "1.0.12",
|
|
46
|
+
"@embedpdf/plugin-interaction-manager": "1.0.12"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"dist",
|
|
@@ -62,11 +62,12 @@
|
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
|
-
"build": "
|
|
66
|
-
"build:
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
65
|
+
"build:base": "vite build --mode base",
|
|
66
|
+
"build:react": "vite build --mode react",
|
|
67
|
+
"build:preact": "vite build --mode preact",
|
|
68
|
+
"build": "pnpm run clean && concurrently -c auto -n base,react,preact \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\"",
|
|
69
|
+
"clean": "rimraf dist",
|
|
70
|
+
"lint": "eslint src --color",
|
|
71
|
+
"lint:fix": "eslint src --color --fix"
|
|
71
72
|
}
|
|
72
73
|
}
|
package/dist/index.d.cts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { BasePluginConfig, EventHook, Action, BasePlugin, PluginRegistry, PluginManifest, PluginPackage } from '@embedpdf/core';
|
|
2
|
-
import { Rect } from '@embedpdf/models';
|
|
3
|
-
import { ViewportMetrics } from '@embedpdf/plugin-viewport';
|
|
4
|
-
|
|
5
|
-
declare enum ZoomMode {
|
|
6
|
-
Automatic = "automatic",
|
|
7
|
-
FitPage = "fit-page",
|
|
8
|
-
FitWidth = "fit-width"
|
|
9
|
-
}
|
|
10
|
-
type ZoomLevel = ZoomMode | number;
|
|
11
|
-
interface Point {
|
|
12
|
-
vx: number;
|
|
13
|
-
vy: number;
|
|
14
|
-
}
|
|
15
|
-
interface ZoomChangeEvent {
|
|
16
|
-
/** old and new *actual* scale factors */
|
|
17
|
-
oldZoom: number;
|
|
18
|
-
newZoom: number;
|
|
19
|
-
/** level used to obtain the newZoom (number | mode) */
|
|
20
|
-
level: ZoomLevel;
|
|
21
|
-
/** viewport point kept under the finger / mouse‑wheel focus */
|
|
22
|
-
center: Point;
|
|
23
|
-
/** where the viewport should scroll to after the scale change */
|
|
24
|
-
desiredScrollLeft: number;
|
|
25
|
-
desiredScrollTop: number;
|
|
26
|
-
/** metrics at the moment the zoom was requested */
|
|
27
|
-
viewport: ViewportMetrics;
|
|
28
|
-
}
|
|
29
|
-
interface ZoomCapability {
|
|
30
|
-
/** subscribe – returns the unsubscribe function */
|
|
31
|
-
onZoomChange: EventHook<ZoomChangeEvent>;
|
|
32
|
-
/** subscribe – returns the unsubscribe function */
|
|
33
|
-
onStateChange: EventHook<ZoomState>;
|
|
34
|
-
/** absolute requests -------------------------------------------------- */
|
|
35
|
-
requestZoom(level: ZoomLevel, center?: Point): void;
|
|
36
|
-
/** relative requests -------------------------------------------------- */
|
|
37
|
-
requestZoomBy(delta: number, center?: Point): void;
|
|
38
|
-
/** absolute requests -------------------------------------------------- */
|
|
39
|
-
zoomIn(): void;
|
|
40
|
-
zoomOut(): void;
|
|
41
|
-
zoomToArea(pageIndex: number, rect: Rect): void;
|
|
42
|
-
/** zoom in on an area -------------------------------------------------- */
|
|
43
|
-
enableMarqueeZoom(): void;
|
|
44
|
-
disableMarqueeZoom(): void;
|
|
45
|
-
toggleMarqueeZoom(): void;
|
|
46
|
-
isMarqueeZoomActive(): boolean;
|
|
47
|
-
getState(): ZoomState;
|
|
48
|
-
getPresets(): ZoomPreset[];
|
|
49
|
-
}
|
|
50
|
-
interface ZoomRangeStep {
|
|
51
|
-
min: number;
|
|
52
|
-
max: number;
|
|
53
|
-
step: number;
|
|
54
|
-
}
|
|
55
|
-
interface ZoomPreset {
|
|
56
|
-
name: string;
|
|
57
|
-
value: ZoomLevel;
|
|
58
|
-
icon?: string;
|
|
59
|
-
}
|
|
60
|
-
interface ZoomPluginConfig extends BasePluginConfig {
|
|
61
|
-
defaultZoomLevel: ZoomLevel;
|
|
62
|
-
minZoom?: number;
|
|
63
|
-
maxZoom?: number;
|
|
64
|
-
zoomStep?: number;
|
|
65
|
-
zoomRanges?: ZoomRangeStep[];
|
|
66
|
-
presets?: ZoomPreset[];
|
|
67
|
-
}
|
|
68
|
-
interface ZoomState {
|
|
69
|
-
zoomLevel: ZoomLevel;
|
|
70
|
-
currentZoomLevel: number;
|
|
71
|
-
}
|
|
72
|
-
declare enum VerticalZoomFocus {
|
|
73
|
-
Center = 0,
|
|
74
|
-
Top = 1
|
|
75
|
-
}
|
|
76
|
-
interface ZoomRequest {
|
|
77
|
-
level: ZoomLevel;
|
|
78
|
-
delta?: number;
|
|
79
|
-
center?: Point;
|
|
80
|
-
focus?: VerticalZoomFocus;
|
|
81
|
-
/** Scroll so that the focal point ends up …
|
|
82
|
-
* ▸ `"keep"` (default) at the same viewport coords
|
|
83
|
-
* ▸ `"center"` centred in the viewport */
|
|
84
|
-
align?: 'keep' | 'center';
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
declare const SET_ZOOM_LEVEL = "SET_ZOOM_LEVEL";
|
|
88
|
-
declare const SET_INITIAL_ZOOM_LEVEL = "SET_INITIAL_ZOOM_LEVEL";
|
|
89
|
-
interface SetZoomLevelAction extends Action {
|
|
90
|
-
type: typeof SET_ZOOM_LEVEL;
|
|
91
|
-
payload: {
|
|
92
|
-
zoomLevel: ZoomLevel;
|
|
93
|
-
currentZoomLevel: number;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
interface SetInitialZoomLevelAction extends Action {
|
|
97
|
-
type: typeof SET_INITIAL_ZOOM_LEVEL;
|
|
98
|
-
payload: {
|
|
99
|
-
zoomLevel: ZoomLevel;
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
type ZoomAction = SetZoomLevelAction | SetInitialZoomLevelAction;
|
|
103
|
-
|
|
104
|
-
declare const initialState: ZoomState;
|
|
105
|
-
|
|
106
|
-
declare class ZoomPlugin extends BasePlugin<ZoomPluginConfig, ZoomCapability, ZoomState, ZoomAction> {
|
|
107
|
-
static readonly id: "zoom";
|
|
108
|
-
private readonly zoom$;
|
|
109
|
-
private readonly state$;
|
|
110
|
-
private readonly viewport;
|
|
111
|
-
private readonly viewportPlugin;
|
|
112
|
-
private readonly scroll;
|
|
113
|
-
private readonly interactionManager;
|
|
114
|
-
private readonly presets;
|
|
115
|
-
private readonly zoomRanges;
|
|
116
|
-
private readonly minZoom;
|
|
117
|
-
private readonly maxZoom;
|
|
118
|
-
private readonly zoomStep;
|
|
119
|
-
constructor(id: string, registry: PluginRegistry, cfg: ZoomPluginConfig);
|
|
120
|
-
protected buildCapability(): ZoomCapability;
|
|
121
|
-
initialize(): Promise<void>;
|
|
122
|
-
destroy(): Promise<void>;
|
|
123
|
-
/**
|
|
124
|
-
* Sort ranges once, make sure they are sane
|
|
125
|
-
*/
|
|
126
|
-
private normalizeRanges;
|
|
127
|
-
/** pick the step that applies to a given numeric zoom */
|
|
128
|
-
private stepFor;
|
|
129
|
-
/** clamp + round helper reused later */
|
|
130
|
-
private toZoom;
|
|
131
|
-
private handleRequest;
|
|
132
|
-
/** numeric zoom for Automatic / FitPage / FitWidth */
|
|
133
|
-
private computeZoomForMode;
|
|
134
|
-
/** where to scroll so that *focus* stays stable after scaling */
|
|
135
|
-
private computeScrollForZoomChange;
|
|
136
|
-
private handleZoomToArea;
|
|
137
|
-
/** recalculates Automatic / Fit* when viewport or pages change */
|
|
138
|
-
private recalcAuto;
|
|
139
|
-
onStoreUpdated(_prevState: ZoomState, newState: ZoomState): void;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
declare const ZOOM_PLUGIN_ID = "zoom";
|
|
143
|
-
declare const manifest: PluginManifest<ZoomPluginConfig>;
|
|
144
|
-
|
|
145
|
-
declare const ZoomPluginPackage: PluginPackage<ZoomPlugin, ZoomPluginConfig, ZoomState, ZoomAction>;
|
|
146
|
-
|
|
147
|
-
export { type Point, VerticalZoomFocus, ZOOM_PLUGIN_ID, type ZoomCapability, type ZoomChangeEvent, type ZoomLevel, ZoomMode, ZoomPlugin, type ZoomPluginConfig, ZoomPluginPackage, type ZoomPreset, type ZoomRangeStep, type ZoomRequest, type ZoomState, initialState, manifest };
|