@papyrus-sdk/ui-react-native 0.2.18-beta.5 → 0.2.18-beta.7
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/LICENSE +21 -0
- package/dist/chunk-B36LWZCX.mjs +178 -0
- package/dist/chunk-B36LWZCX.mjs.map +1 -0
- package/dist/chunk-KXNP73MZ.mjs +63 -0
- package/dist/chunk-KXNP73MZ.mjs.map +1 -0
- package/dist/chunk-ZD7AOCMD.mjs +9 -0
- package/dist/chunk-ZD7AOCMD.mjs.map +1 -0
- package/dist/gesture/pinchZoom.d.mts +69 -0
- package/dist/gesture/pinchZoom.d.ts +69 -0
- package/dist/gesture/pinchZoom.js +217 -0
- package/dist/gesture/pinchZoom.js.map +1 -0
- package/dist/gesture/pinchZoom.mjs +40 -0
- package/dist/gesture/pinchZoom.mjs.map +1 -0
- package/dist/gesture/selectionInteraction.d.mts +35 -0
- package/dist/gesture/selectionInteraction.d.ts +35 -0
- package/dist/gesture/selectionInteraction.js +90 -0
- package/dist/gesture/selectionInteraction.js.map +1 -0
- package/dist/gesture/selectionInteraction.mjs +16 -0
- package/dist/gesture/selectionInteraction.mjs.map +1 -0
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +45 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +105 -244
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Papyrus Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// gesture/pinchZoom.ts
|
|
2
|
+
var DEFAULT_PINCH_ZOOM_BOUNDS = {
|
|
3
|
+
minZoom: 0.5,
|
|
4
|
+
maxZoom: 4
|
|
5
|
+
};
|
|
6
|
+
var PINCH_PRESS_SUPPRESSION_MS = 120;
|
|
7
|
+
var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
8
|
+
var getTouchDistance = (touches) => {
|
|
9
|
+
if (touches.length < 2) return 0;
|
|
10
|
+
const [first, second] = touches;
|
|
11
|
+
return Math.hypot(second.pageX - first.pageX, second.pageY - first.pageY);
|
|
12
|
+
};
|
|
13
|
+
var isPinchTouchList = (touches) => touches.length === 2 && getTouchDistance(touches) > 0;
|
|
14
|
+
var createPinchSession = (touches, zoom, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => ({
|
|
15
|
+
initialDistance: Math.max(1, getTouchDistance(touches)),
|
|
16
|
+
initialZoom: clamp(zoom, bounds.minZoom, bounds.maxZoom)
|
|
17
|
+
});
|
|
18
|
+
var resolvePinchZoomChange = (session, touches, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => {
|
|
19
|
+
const distance = getTouchDistance(touches);
|
|
20
|
+
if (distance <= 0) {
|
|
21
|
+
return clamp(session.initialZoom, bounds.minZoom, bounds.maxZoom);
|
|
22
|
+
}
|
|
23
|
+
return clamp(
|
|
24
|
+
session.initialZoom * (distance / session.initialDistance),
|
|
25
|
+
bounds.minZoom,
|
|
26
|
+
bounds.maxZoom
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
var resolvePinchPreviewScale = (startZoom, previewZoom) => {
|
|
30
|
+
const safeStartZoom = Math.max(1e-4, Math.abs(startZoom));
|
|
31
|
+
return previewZoom / safeStartZoom;
|
|
32
|
+
};
|
|
33
|
+
var sanitizePinchPreviewScale = (value) => {
|
|
34
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
35
|
+
return 1;
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
};
|
|
39
|
+
var resolvePinchGestureZoom = (startZoom, scaleFactor, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => clamp(
|
|
40
|
+
(Number.isFinite(startZoom) && startZoom > 0 ? startZoom : 1) * (Number.isFinite(scaleFactor) && scaleFactor > 0 ? scaleFactor : 1),
|
|
41
|
+
bounds.minZoom,
|
|
42
|
+
bounds.maxZoom
|
|
43
|
+
);
|
|
44
|
+
var resolveAnchoredViewportOffset = ({
|
|
45
|
+
viewportOffset,
|
|
46
|
+
startScrollOffset,
|
|
47
|
+
startItemOffset,
|
|
48
|
+
startItemLength,
|
|
49
|
+
endItemOffset,
|
|
50
|
+
endItemLength,
|
|
51
|
+
viewportLength,
|
|
52
|
+
endContentLength
|
|
53
|
+
}) => {
|
|
54
|
+
const safeViewportOffset = Number.isFinite(viewportOffset) ? viewportOffset : 0;
|
|
55
|
+
const safeStartScrollOffset = Number.isFinite(startScrollOffset) ? startScrollOffset : 0;
|
|
56
|
+
const safeStartItemOffset = Number.isFinite(startItemOffset) ? startItemOffset : 0;
|
|
57
|
+
const safeStartItemLength = Number.isFinite(startItemLength) && startItemLength > 0 ? startItemLength : 1;
|
|
58
|
+
const safeEndItemOffset = Number.isFinite(endItemOffset) ? endItemOffset : 0;
|
|
59
|
+
const safeEndItemLength = Number.isFinite(endItemLength) && endItemLength > 0 ? endItemLength : 1;
|
|
60
|
+
const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
|
|
61
|
+
const safeEndContentLength = Number.isFinite(endContentLength) && endContentLength > 0 ? endContentLength : safeEndItemOffset + safeEndItemLength;
|
|
62
|
+
const contentPoint = safeStartScrollOffset + safeViewportOffset - safeStartItemOffset;
|
|
63
|
+
const normalizedPoint = clamp(contentPoint / safeStartItemLength, 0, 1);
|
|
64
|
+
const anchoredContentPoint = safeEndItemOffset + normalizedPoint * safeEndItemLength;
|
|
65
|
+
return clamp(
|
|
66
|
+
anchoredContentPoint - safeViewportOffset,
|
|
67
|
+
0,
|
|
68
|
+
Math.max(0, safeEndContentLength - safeViewportLength)
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
var resolveAnchoredDocumentOffset = ({
|
|
72
|
+
viewportOffset,
|
|
73
|
+
startScrollOffset,
|
|
74
|
+
startContentLength,
|
|
75
|
+
endContentLength,
|
|
76
|
+
viewportLength
|
|
77
|
+
}) => {
|
|
78
|
+
const safeViewportOffset = Number.isFinite(viewportOffset) ? viewportOffset : 0;
|
|
79
|
+
const safeStartScrollOffset = Number.isFinite(startScrollOffset) ? startScrollOffset : 0;
|
|
80
|
+
const safeStartContentLength = Number.isFinite(startContentLength) && startContentLength > 0 ? startContentLength : 1;
|
|
81
|
+
const safeEndContentLength = Number.isFinite(endContentLength) && endContentLength > 0 ? endContentLength : 0;
|
|
82
|
+
const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
|
|
83
|
+
const anchoredRatio = clamp(
|
|
84
|
+
(safeStartScrollOffset + safeViewportOffset) / safeStartContentLength,
|
|
85
|
+
0,
|
|
86
|
+
1
|
|
87
|
+
);
|
|
88
|
+
return resolveClampedScrollOffset(
|
|
89
|
+
anchoredRatio * safeEndContentLength - safeViewportOffset,
|
|
90
|
+
safeEndContentLength,
|
|
91
|
+
safeViewportLength
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
var resolveClampedScrollOffset = (offset, contentLength, viewportLength) => {
|
|
95
|
+
const safeOffset = Number.isFinite(offset) ? offset : 0;
|
|
96
|
+
const safeContentLength = Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;
|
|
97
|
+
const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
|
|
98
|
+
return clamp(
|
|
99
|
+
safeOffset,
|
|
100
|
+
0,
|
|
101
|
+
Math.max(0, safeContentLength - safeViewportLength)
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
var resolveDocumentSurfaceWidth = ({
|
|
105
|
+
viewportWidth,
|
|
106
|
+
contentWidth,
|
|
107
|
+
horizontalPadding
|
|
108
|
+
}) => {
|
|
109
|
+
const safeViewportWidth = Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;
|
|
110
|
+
const safeContentWidth = Number.isFinite(contentWidth) && contentWidth > 0 ? contentWidth : 0;
|
|
111
|
+
const safeHorizontalPadding = Number.isFinite(horizontalPadding) && horizontalPadding > 0 ? horizontalPadding : 0;
|
|
112
|
+
return Math.max(
|
|
113
|
+
safeViewportWidth,
|
|
114
|
+
safeContentWidth + safeHorizontalPadding * 2
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
var resolveGlobalHorizontalOffset = ({
|
|
118
|
+
offsetX,
|
|
119
|
+
surfaceWidth,
|
|
120
|
+
viewportWidth
|
|
121
|
+
}) => resolveClampedScrollOffset(offsetX, surfaceWidth, viewportWidth);
|
|
122
|
+
var resolveAnchoredHorizontalSurfaceOffset = ({
|
|
123
|
+
focalViewportX,
|
|
124
|
+
startSurfaceScrollX,
|
|
125
|
+
startSurfaceWidth,
|
|
126
|
+
endSurfaceWidth,
|
|
127
|
+
viewportWidth
|
|
128
|
+
}) => {
|
|
129
|
+
const safeFocalViewportX = Number.isFinite(focalViewportX) ? focalViewportX : 0;
|
|
130
|
+
const safeStartSurfaceScrollX = Number.isFinite(startSurfaceScrollX) ? startSurfaceScrollX : 0;
|
|
131
|
+
const safeStartSurfaceWidth = Number.isFinite(startSurfaceWidth) && startSurfaceWidth > 0 ? startSurfaceWidth : 1;
|
|
132
|
+
const safeEndSurfaceWidth = Number.isFinite(endSurfaceWidth) && endSurfaceWidth > 0 ? endSurfaceWidth : 0;
|
|
133
|
+
const safeViewportWidth = Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;
|
|
134
|
+
const anchoredRatio = clamp(
|
|
135
|
+
(safeStartSurfaceScrollX + safeFocalViewportX) / safeStartSurfaceWidth,
|
|
136
|
+
0,
|
|
137
|
+
1
|
|
138
|
+
);
|
|
139
|
+
return resolveGlobalHorizontalOffset({
|
|
140
|
+
offsetX: anchoredRatio * safeEndSurfaceWidth - safeFocalViewportX,
|
|
141
|
+
surfaceWidth: safeEndSurfaceWidth,
|
|
142
|
+
viewportWidth: safeViewportWidth
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
var resolveCenteredContentInset = ({
|
|
146
|
+
viewportLength,
|
|
147
|
+
contentLength
|
|
148
|
+
}) => {
|
|
149
|
+
const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
|
|
150
|
+
const safeContentLength = Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;
|
|
151
|
+
return Math.max(0, (safeViewportLength - safeContentLength) / 2);
|
|
152
|
+
};
|
|
153
|
+
var shouldSuppressPressAfterPinch = (lastPinchEndedAt, now = Date.now(), windowMs = PINCH_PRESS_SUPPRESSION_MS) => {
|
|
154
|
+
if (typeof lastPinchEndedAt !== "number") return false;
|
|
155
|
+
const elapsedMs = now - lastPinchEndedAt;
|
|
156
|
+
return elapsedMs >= 0 && elapsedMs < windowMs;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export {
|
|
160
|
+
DEFAULT_PINCH_ZOOM_BOUNDS,
|
|
161
|
+
PINCH_PRESS_SUPPRESSION_MS,
|
|
162
|
+
getTouchDistance,
|
|
163
|
+
isPinchTouchList,
|
|
164
|
+
createPinchSession,
|
|
165
|
+
resolvePinchZoomChange,
|
|
166
|
+
resolvePinchPreviewScale,
|
|
167
|
+
sanitizePinchPreviewScale,
|
|
168
|
+
resolvePinchGestureZoom,
|
|
169
|
+
resolveAnchoredViewportOffset,
|
|
170
|
+
resolveAnchoredDocumentOffset,
|
|
171
|
+
resolveClampedScrollOffset,
|
|
172
|
+
resolveDocumentSurfaceWidth,
|
|
173
|
+
resolveGlobalHorizontalOffset,
|
|
174
|
+
resolveAnchoredHorizontalSurfaceOffset,
|
|
175
|
+
resolveCenteredContentInset,
|
|
176
|
+
shouldSuppressPressAfterPinch
|
|
177
|
+
};
|
|
178
|
+
//# sourceMappingURL=chunk-B36LWZCX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../gesture/pinchZoom.ts"],"sourcesContent":["export type PinchTouchPoint = {\n pageX: number;\n pageY: number;\n};\n\nexport type PinchSession = {\n initialDistance: number;\n initialZoom: number;\n};\n\nexport type PinchZoomBounds = {\n minZoom: number;\n maxZoom: number;\n};\n\nexport type AnchoredViewportOffsetInput = {\n viewportOffset: number;\n startScrollOffset: number;\n startItemOffset: number;\n startItemLength: number;\n endItemOffset: number;\n endItemLength: number;\n viewportLength: number;\n endContentLength: number;\n};\n\nexport type AnchoredDocumentOffsetInput = {\n viewportOffset: number;\n startScrollOffset: number;\n startContentLength: number;\n endContentLength: number;\n viewportLength: number;\n};\n\nexport type DocumentSurfaceWidthInput = {\n viewportWidth: number;\n contentWidth: number;\n horizontalPadding: number;\n};\n\nexport type GlobalHorizontalOffsetInput = {\n offsetX: number;\n surfaceWidth: number;\n viewportWidth: number;\n};\n\nexport type AnchoredHorizontalSurfaceOffsetInput = {\n focalViewportX: number;\n startSurfaceScrollX: number;\n startSurfaceWidth: number;\n endSurfaceWidth: number;\n viewportWidth: number;\n};\n\nexport type CenteredContentInsetInput = {\n viewportLength: number;\n contentLength: number;\n};\n\nexport const DEFAULT_PINCH_ZOOM_BOUNDS: PinchZoomBounds = {\n minZoom: 0.5,\n maxZoom: 4,\n};\nexport const PINCH_PRESS_SUPPRESSION_MS = 120;\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\n\nexport const getTouchDistance = (touches: PinchTouchPoint[]): number => {\n if (touches.length < 2) return 0;\n const [first, second] = touches;\n return Math.hypot(second.pageX - first.pageX, second.pageY - first.pageY);\n};\n\nexport const isPinchTouchList = (touches: PinchTouchPoint[]): boolean =>\n touches.length === 2 && getTouchDistance(touches) > 0;\n\nexport const createPinchSession = (\n touches: PinchTouchPoint[],\n zoom: number,\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): PinchSession => ({\n initialDistance: Math.max(1, getTouchDistance(touches)),\n initialZoom: clamp(zoom, bounds.minZoom, bounds.maxZoom),\n});\n\nexport const resolvePinchZoomChange = (\n session: PinchSession,\n touches: PinchTouchPoint[],\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): number => {\n const distance = getTouchDistance(touches);\n if (distance <= 0) {\n return clamp(session.initialZoom, bounds.minZoom, bounds.maxZoom);\n }\n\n return clamp(\n session.initialZoom * (distance / session.initialDistance),\n bounds.minZoom,\n bounds.maxZoom\n );\n};\n\nexport const resolvePinchPreviewScale = (\n startZoom: number,\n previewZoom: number\n): number => {\n const safeStartZoom = Math.max(0.0001, Math.abs(startZoom));\n return previewZoom / safeStartZoom;\n};\n\nexport const sanitizePinchPreviewScale = (value: number): number => {\n if (!Number.isFinite(value) || value <= 0) {\n return 1;\n }\n return value;\n};\n\nexport const resolvePinchGestureZoom = (\n startZoom: number,\n scaleFactor: number,\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): number =>\n clamp(\n (Number.isFinite(startZoom) && startZoom > 0 ? startZoom : 1) *\n (Number.isFinite(scaleFactor) && scaleFactor > 0 ? scaleFactor : 1),\n bounds.minZoom,\n bounds.maxZoom\n );\n\nexport const resolveAnchoredViewportOffset = ({\n viewportOffset,\n startScrollOffset,\n startItemOffset,\n startItemLength,\n endItemOffset,\n endItemLength,\n viewportLength,\n endContentLength,\n}: AnchoredViewportOffsetInput): number => {\n const safeViewportOffset = Number.isFinite(viewportOffset)\n ? viewportOffset\n : 0;\n const safeStartScrollOffset = Number.isFinite(startScrollOffset)\n ? startScrollOffset\n : 0;\n const safeStartItemOffset = Number.isFinite(startItemOffset)\n ? startItemOffset\n : 0;\n const safeStartItemLength =\n Number.isFinite(startItemLength) && startItemLength > 0\n ? startItemLength\n : 1;\n const safeEndItemOffset = Number.isFinite(endItemOffset) ? endItemOffset : 0;\n const safeEndItemLength =\n Number.isFinite(endItemLength) && endItemLength > 0 ? endItemLength : 1;\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n const safeEndContentLength =\n Number.isFinite(endContentLength) && endContentLength > 0\n ? endContentLength\n : safeEndItemOffset + safeEndItemLength;\n\n const contentPoint =\n safeStartScrollOffset + safeViewportOffset - safeStartItemOffset;\n const normalizedPoint = clamp(contentPoint / safeStartItemLength, 0, 1);\n const anchoredContentPoint =\n safeEndItemOffset + normalizedPoint * safeEndItemLength;\n return clamp(\n anchoredContentPoint - safeViewportOffset,\n 0,\n Math.max(0, safeEndContentLength - safeViewportLength)\n );\n};\n\nexport const resolveAnchoredDocumentOffset = ({\n viewportOffset,\n startScrollOffset,\n startContentLength,\n endContentLength,\n viewportLength,\n}: AnchoredDocumentOffsetInput): number => {\n const safeViewportOffset = Number.isFinite(viewportOffset)\n ? viewportOffset\n : 0;\n const safeStartScrollOffset = Number.isFinite(startScrollOffset)\n ? startScrollOffset\n : 0;\n const safeStartContentLength =\n Number.isFinite(startContentLength) && startContentLength > 0\n ? startContentLength\n : 1;\n const safeEndContentLength =\n Number.isFinite(endContentLength) && endContentLength > 0\n ? endContentLength\n : 0;\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n\n const anchoredRatio = clamp(\n (safeStartScrollOffset + safeViewportOffset) / safeStartContentLength,\n 0,\n 1\n );\n\n return resolveClampedScrollOffset(\n anchoredRatio * safeEndContentLength - safeViewportOffset,\n safeEndContentLength,\n safeViewportLength\n );\n};\n\nexport const resolveClampedScrollOffset = (\n offset: number,\n contentLength: number,\n viewportLength: number\n): number => {\n const safeOffset = Number.isFinite(offset) ? offset : 0;\n const safeContentLength =\n Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n return clamp(\n safeOffset,\n 0,\n Math.max(0, safeContentLength - safeViewportLength)\n );\n};\n\nexport const resolveDocumentSurfaceWidth = ({\n viewportWidth,\n contentWidth,\n horizontalPadding,\n}: DocumentSurfaceWidthInput): number => {\n const safeViewportWidth =\n Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;\n const safeContentWidth =\n Number.isFinite(contentWidth) && contentWidth > 0 ? contentWidth : 0;\n const safeHorizontalPadding =\n Number.isFinite(horizontalPadding) && horizontalPadding > 0\n ? horizontalPadding\n : 0;\n\n return Math.max(\n safeViewportWidth,\n safeContentWidth + safeHorizontalPadding * 2\n );\n};\n\nexport const resolveGlobalHorizontalOffset = ({\n offsetX,\n surfaceWidth,\n viewportWidth,\n}: GlobalHorizontalOffsetInput): number =>\n resolveClampedScrollOffset(offsetX, surfaceWidth, viewportWidth);\n\nexport const resolveAnchoredHorizontalSurfaceOffset = ({\n focalViewportX,\n startSurfaceScrollX,\n startSurfaceWidth,\n endSurfaceWidth,\n viewportWidth,\n}: AnchoredHorizontalSurfaceOffsetInput): number => {\n const safeFocalViewportX = Number.isFinite(focalViewportX)\n ? focalViewportX\n : 0;\n const safeStartSurfaceScrollX = Number.isFinite(startSurfaceScrollX)\n ? startSurfaceScrollX\n : 0;\n const safeStartSurfaceWidth =\n Number.isFinite(startSurfaceWidth) && startSurfaceWidth > 0\n ? startSurfaceWidth\n : 1;\n const safeEndSurfaceWidth =\n Number.isFinite(endSurfaceWidth) && endSurfaceWidth > 0\n ? endSurfaceWidth\n : 0;\n const safeViewportWidth =\n Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;\n\n const anchoredRatio = clamp(\n (safeStartSurfaceScrollX + safeFocalViewportX) / safeStartSurfaceWidth,\n 0,\n 1\n );\n\n return resolveGlobalHorizontalOffset({\n offsetX: anchoredRatio * safeEndSurfaceWidth - safeFocalViewportX,\n surfaceWidth: safeEndSurfaceWidth,\n viewportWidth: safeViewportWidth,\n });\n};\n\nexport const resolveCenteredContentInset = ({\n viewportLength,\n contentLength,\n}: CenteredContentInsetInput): number => {\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n const safeContentLength =\n Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;\n return Math.max(0, (safeViewportLength - safeContentLength) / 2);\n};\n\nexport const shouldSuppressPressAfterPinch = (\n lastPinchEndedAt: number | null | undefined,\n now = Date.now(),\n windowMs = PINCH_PRESS_SUPPRESSION_MS\n): boolean => {\n if (typeof lastPinchEndedAt !== \"number\") return false;\n const elapsedMs = now - lastPinchEndedAt;\n return elapsedMs >= 0 && elapsedMs < windowMs;\n};\n"],"mappings":";AA2DO,IAAM,4BAA6C;AAAA,EACxD,SAAS;AAAA,EACT,SAAS;AACX;AACO,IAAM,6BAA6B;AAE1C,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAE7B,IAAM,mBAAmB,CAAC,YAAuC;AACtE,MAAI,QAAQ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B;AAAA,IACjD;AAAA,IACA;AAAA,EACF;AAEA,SAAO,8BAA8B;AAAA,IACnC,SAAS,gBAAgB,sBAAsB;AAAA,IAC/C,cAAc;AAAA,IACd,eAAe;AAAA,EACjB,CAAC;AACH;AAEO,IAAM,8BAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;AACF,MAAyC;AACvC,QAAM,qBACJ,OAAO,SAAS,cAAc,KAAK,iBAAiB,IAAI,iBAAiB;AAC3E,QAAM,oBACJ,OAAO,SAAS,aAAa,KAAK,gBAAgB,IAAI,gBAAgB;AACxE,SAAO,KAAK,IAAI,IAAI,qBAAqB,qBAAqB,CAAC;AACjE;AAEO,IAAM,gCAAgC,CAC3C,kBACA,MAAM,KAAK,IAAI,GACf,WAAW,+BACC;AACZ,MAAI,OAAO,qBAAqB,SAAU,QAAO;AACjD,QAAM,YAAY,MAAM;AACxB,SAAO,aAAa,KAAK,YAAY;AACvC;","names":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// gesture/selectionInteraction.ts
|
|
2
|
+
var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
3
|
+
var DRAG_SELECTION_TOOLS = /* @__PURE__ */ new Set([
|
|
4
|
+
"highlight",
|
|
5
|
+
"underline",
|
|
6
|
+
"squiggly",
|
|
7
|
+
"strikeout"
|
|
8
|
+
]);
|
|
9
|
+
var resolveAxisAutoscroll = (coordinate, size, threshold, maxStep) => {
|
|
10
|
+
if (size <= 0 || threshold <= 0 || maxStep <= 0) return 0;
|
|
11
|
+
const startDistance = clamp(coordinate, 0, size);
|
|
12
|
+
if (startDistance < threshold) {
|
|
13
|
+
const intensity = 1 - startDistance / threshold;
|
|
14
|
+
return -Math.round(maxStep * intensity);
|
|
15
|
+
}
|
|
16
|
+
const endDistance = clamp(size - coordinate, 0, size);
|
|
17
|
+
if (endDistance < threshold) {
|
|
18
|
+
const intensity = 1 - endDistance / threshold;
|
|
19
|
+
return Math.round(maxStep * intensity);
|
|
20
|
+
}
|
|
21
|
+
return 0;
|
|
22
|
+
};
|
|
23
|
+
var shouldEnableViewerScroll = ({
|
|
24
|
+
selectionDragActive,
|
|
25
|
+
gestureScrollLockActive = false
|
|
26
|
+
}) => !selectionDragActive && !gestureScrollLockActive;
|
|
27
|
+
var shouldEnableSelectionDrag = ({
|
|
28
|
+
activeTool,
|
|
29
|
+
interactionMode
|
|
30
|
+
}) => DRAG_SELECTION_TOOLS.has(activeTool) || activeTool === "select" && interactionMode === "select";
|
|
31
|
+
var isToolDockToolSelected = ({
|
|
32
|
+
activeTool,
|
|
33
|
+
interactionMode,
|
|
34
|
+
toolId
|
|
35
|
+
}) => toolId === "select" ? activeTool === "select" && interactionMode === "select" : activeTool === toolId;
|
|
36
|
+
var getToolDockDismissState = ({
|
|
37
|
+
activeTool: _activeTool,
|
|
38
|
+
interactionMode: _interactionMode
|
|
39
|
+
}) => ({
|
|
40
|
+
toolDockOpen: false,
|
|
41
|
+
activeTool: "select",
|
|
42
|
+
interactionMode: "pan"
|
|
43
|
+
});
|
|
44
|
+
var getSelectionEdgeAutoscroll = ({
|
|
45
|
+
x,
|
|
46
|
+
y,
|
|
47
|
+
width,
|
|
48
|
+
height,
|
|
49
|
+
threshold,
|
|
50
|
+
maxStep
|
|
51
|
+
}) => ({
|
|
52
|
+
dx: resolveAxisAutoscroll(x, width, threshold, maxStep),
|
|
53
|
+
dy: resolveAxisAutoscroll(y, height, threshold, maxStep)
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
shouldEnableViewerScroll,
|
|
58
|
+
shouldEnableSelectionDrag,
|
|
59
|
+
isToolDockToolSelected,
|
|
60
|
+
getToolDockDismissState,
|
|
61
|
+
getSelectionEdgeAutoscroll
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=chunk-KXNP73MZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../gesture/selectionInteraction.ts"],"sourcesContent":["export type ViewerScrollState = {\n selectionDragActive: boolean;\n gestureScrollLockActive?: boolean;\n};\n\nexport type SelectionGestureTool =\n | \"select\"\n | \"highlight\"\n | \"underline\"\n | \"squiggly\"\n | \"strikeout\"\n | \"text\"\n | \"comment\"\n | \"ink\";\n\nexport type SelectionInteractionMode = \"pan\" | \"select\";\n\nexport type SelectionGestureActivationInput = {\n activeTool: SelectionGestureTool;\n interactionMode: SelectionInteractionMode;\n};\n\nexport type ToolDockSelectionState = SelectionGestureActivationInput & {\n toolId: SelectionGestureTool;\n};\n\nexport type ToolDockDismissState = SelectionGestureActivationInput & {\n toolDockOpen: boolean;\n};\n\nexport type SelectionEdgeAutoscrollInput = {\n x: number;\n y: number;\n width: number;\n height: number;\n threshold: number;\n maxStep: number;\n};\n\nexport type SelectionEdgeAutoscroll = {\n dx: number;\n dy: number;\n};\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\n\nconst DRAG_SELECTION_TOOLS = new Set<SelectionGestureTool>([\n \"highlight\",\n \"underline\",\n \"squiggly\",\n \"strikeout\",\n]);\n\nconst resolveAxisAutoscroll = (\n coordinate: number,\n size: number,\n threshold: number,\n maxStep: number\n) => {\n if (size <= 0 || threshold <= 0 || maxStep <= 0) return 0;\n\n const startDistance = clamp(coordinate, 0, size);\n if (startDistance < threshold) {\n const intensity = 1 - startDistance / threshold;\n return -Math.round(maxStep * intensity);\n }\n\n const endDistance = clamp(size - coordinate, 0, size);\n if (endDistance < threshold) {\n const intensity = 1 - endDistance / threshold;\n return Math.round(maxStep * intensity);\n }\n\n return 0;\n};\n\nexport const shouldEnableViewerScroll = ({\n selectionDragActive,\n gestureScrollLockActive = false,\n}: ViewerScrollState) => !selectionDragActive && !gestureScrollLockActive;\n\nexport const shouldEnableSelectionDrag = ({\n activeTool,\n interactionMode,\n}: SelectionGestureActivationInput) =>\n DRAG_SELECTION_TOOLS.has(activeTool) ||\n (activeTool === \"select\" && interactionMode === \"select\");\n\nexport const isToolDockToolSelected = ({\n activeTool,\n interactionMode,\n toolId,\n}: ToolDockSelectionState) =>\n toolId === \"select\"\n ? activeTool === \"select\" && interactionMode === \"select\"\n : activeTool === toolId;\n\nexport const getToolDockDismissState = ({\n activeTool: _activeTool,\n interactionMode: _interactionMode,\n}: SelectionGestureActivationInput): ToolDockDismissState => ({\n toolDockOpen: false,\n activeTool: \"select\",\n interactionMode: \"pan\",\n});\n\nexport const getSelectionEdgeAutoscroll = ({\n x,\n y,\n width,\n height,\n threshold,\n maxStep,\n}: SelectionEdgeAutoscrollInput): SelectionEdgeAutoscroll => ({\n dx: resolveAxisAutoscroll(x, width, threshold, maxStep),\n dy: resolveAxisAutoscroll(y, height, threshold, maxStep),\n});\n"],"mappings":";AA4CA,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAEpC,IAAM,uBAAuB,oBAAI,IAA0B;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,wBAAwB,CAC5B,YACA,MACA,WACA,YACG;AACH,MAAI,QAAQ,KAAK,aAAa,KAAK,WAAW,EAAG,QAAO;AAExD,QAAM,gBAAgB,MAAM,YAAY,GAAG,IAAI;AAC/C,MAAI,gBAAgB,WAAW;AAC7B,UAAM,YAAY,IAAI,gBAAgB;AACtC,WAAO,CAAC,KAAK,MAAM,UAAU,SAAS;AAAA,EACxC;AAEA,QAAM,cAAc,MAAM,OAAO,YAAY,GAAG,IAAI;AACpD,MAAI,cAAc,WAAW;AAC3B,UAAM,YAAY,IAAI,cAAc;AACpC,WAAO,KAAK,MAAM,UAAU,SAAS;AAAA,EACvC;AAEA,SAAO;AACT;AAEO,IAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA,0BAA0B;AAC5B,MAAyB,CAAC,uBAAuB,CAAC;AAE3C,IAAM,4BAA4B,CAAC;AAAA,EACxC;AAAA,EACA;AACF,MACE,qBAAqB,IAAI,UAAU,KAClC,eAAe,YAAY,oBAAoB;AAE3C,IAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACF,MACE,WAAW,WACP,eAAe,YAAY,oBAAoB,WAC/C,eAAe;AAEd,IAAM,0BAA0B,CAAC;AAAA,EACtC,YAAY;AAAA,EACZ,iBAAiB;AACnB,OAA8D;AAAA,EAC5D,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,iBAAiB;AACnB;AAEO,IAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,OAA8D;AAAA,EAC5D,IAAI,sBAAsB,GAAG,OAAO,WAAW,OAAO;AAAA,EACtD,IAAI,sBAAsB,GAAG,QAAQ,WAAW,OAAO;AACzD;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
__commonJS
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=chunk-ZD7AOCMD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
type PinchTouchPoint = {
|
|
2
|
+
pageX: number;
|
|
3
|
+
pageY: number;
|
|
4
|
+
};
|
|
5
|
+
type PinchSession = {
|
|
6
|
+
initialDistance: number;
|
|
7
|
+
initialZoom: number;
|
|
8
|
+
};
|
|
9
|
+
type PinchZoomBounds = {
|
|
10
|
+
minZoom: number;
|
|
11
|
+
maxZoom: number;
|
|
12
|
+
};
|
|
13
|
+
type AnchoredViewportOffsetInput = {
|
|
14
|
+
viewportOffset: number;
|
|
15
|
+
startScrollOffset: number;
|
|
16
|
+
startItemOffset: number;
|
|
17
|
+
startItemLength: number;
|
|
18
|
+
endItemOffset: number;
|
|
19
|
+
endItemLength: number;
|
|
20
|
+
viewportLength: number;
|
|
21
|
+
endContentLength: number;
|
|
22
|
+
};
|
|
23
|
+
type AnchoredDocumentOffsetInput = {
|
|
24
|
+
viewportOffset: number;
|
|
25
|
+
startScrollOffset: number;
|
|
26
|
+
startContentLength: number;
|
|
27
|
+
endContentLength: number;
|
|
28
|
+
viewportLength: number;
|
|
29
|
+
};
|
|
30
|
+
type DocumentSurfaceWidthInput = {
|
|
31
|
+
viewportWidth: number;
|
|
32
|
+
contentWidth: number;
|
|
33
|
+
horizontalPadding: number;
|
|
34
|
+
};
|
|
35
|
+
type GlobalHorizontalOffsetInput = {
|
|
36
|
+
offsetX: number;
|
|
37
|
+
surfaceWidth: number;
|
|
38
|
+
viewportWidth: number;
|
|
39
|
+
};
|
|
40
|
+
type AnchoredHorizontalSurfaceOffsetInput = {
|
|
41
|
+
focalViewportX: number;
|
|
42
|
+
startSurfaceScrollX: number;
|
|
43
|
+
startSurfaceWidth: number;
|
|
44
|
+
endSurfaceWidth: number;
|
|
45
|
+
viewportWidth: number;
|
|
46
|
+
};
|
|
47
|
+
type CenteredContentInsetInput = {
|
|
48
|
+
viewportLength: number;
|
|
49
|
+
contentLength: number;
|
|
50
|
+
};
|
|
51
|
+
declare const DEFAULT_PINCH_ZOOM_BOUNDS: PinchZoomBounds;
|
|
52
|
+
declare const PINCH_PRESS_SUPPRESSION_MS = 120;
|
|
53
|
+
declare const getTouchDistance: (touches: PinchTouchPoint[]) => number;
|
|
54
|
+
declare const isPinchTouchList: (touches: PinchTouchPoint[]) => boolean;
|
|
55
|
+
declare const createPinchSession: (touches: PinchTouchPoint[], zoom: number, bounds?: PinchZoomBounds) => PinchSession;
|
|
56
|
+
declare const resolvePinchZoomChange: (session: PinchSession, touches: PinchTouchPoint[], bounds?: PinchZoomBounds) => number;
|
|
57
|
+
declare const resolvePinchPreviewScale: (startZoom: number, previewZoom: number) => number;
|
|
58
|
+
declare const sanitizePinchPreviewScale: (value: number) => number;
|
|
59
|
+
declare const resolvePinchGestureZoom: (startZoom: number, scaleFactor: number, bounds?: PinchZoomBounds) => number;
|
|
60
|
+
declare const resolveAnchoredViewportOffset: ({ viewportOffset, startScrollOffset, startItemOffset, startItemLength, endItemOffset, endItemLength, viewportLength, endContentLength, }: AnchoredViewportOffsetInput) => number;
|
|
61
|
+
declare const resolveAnchoredDocumentOffset: ({ viewportOffset, startScrollOffset, startContentLength, endContentLength, viewportLength, }: AnchoredDocumentOffsetInput) => number;
|
|
62
|
+
declare const resolveClampedScrollOffset: (offset: number, contentLength: number, viewportLength: number) => number;
|
|
63
|
+
declare const resolveDocumentSurfaceWidth: ({ viewportWidth, contentWidth, horizontalPadding, }: DocumentSurfaceWidthInput) => number;
|
|
64
|
+
declare const resolveGlobalHorizontalOffset: ({ offsetX, surfaceWidth, viewportWidth, }: GlobalHorizontalOffsetInput) => number;
|
|
65
|
+
declare const resolveAnchoredHorizontalSurfaceOffset: ({ focalViewportX, startSurfaceScrollX, startSurfaceWidth, endSurfaceWidth, viewportWidth, }: AnchoredHorizontalSurfaceOffsetInput) => number;
|
|
66
|
+
declare const resolveCenteredContentInset: ({ viewportLength, contentLength, }: CenteredContentInsetInput) => number;
|
|
67
|
+
declare const shouldSuppressPressAfterPinch: (lastPinchEndedAt: number | null | undefined, now?: number, windowMs?: number) => boolean;
|
|
68
|
+
|
|
69
|
+
export { type AnchoredDocumentOffsetInput, type AnchoredHorizontalSurfaceOffsetInput, type AnchoredViewportOffsetInput, type CenteredContentInsetInput, DEFAULT_PINCH_ZOOM_BOUNDS, type DocumentSurfaceWidthInput, type GlobalHorizontalOffsetInput, PINCH_PRESS_SUPPRESSION_MS, type PinchSession, type PinchTouchPoint, type PinchZoomBounds, createPinchSession, getTouchDistance, isPinchTouchList, resolveAnchoredDocumentOffset, resolveAnchoredHorizontalSurfaceOffset, resolveAnchoredViewportOffset, resolveCenteredContentInset, resolveClampedScrollOffset, resolveDocumentSurfaceWidth, resolveGlobalHorizontalOffset, resolvePinchGestureZoom, resolvePinchPreviewScale, resolvePinchZoomChange, sanitizePinchPreviewScale, shouldSuppressPressAfterPinch };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
type PinchTouchPoint = {
|
|
2
|
+
pageX: number;
|
|
3
|
+
pageY: number;
|
|
4
|
+
};
|
|
5
|
+
type PinchSession = {
|
|
6
|
+
initialDistance: number;
|
|
7
|
+
initialZoom: number;
|
|
8
|
+
};
|
|
9
|
+
type PinchZoomBounds = {
|
|
10
|
+
minZoom: number;
|
|
11
|
+
maxZoom: number;
|
|
12
|
+
};
|
|
13
|
+
type AnchoredViewportOffsetInput = {
|
|
14
|
+
viewportOffset: number;
|
|
15
|
+
startScrollOffset: number;
|
|
16
|
+
startItemOffset: number;
|
|
17
|
+
startItemLength: number;
|
|
18
|
+
endItemOffset: number;
|
|
19
|
+
endItemLength: number;
|
|
20
|
+
viewportLength: number;
|
|
21
|
+
endContentLength: number;
|
|
22
|
+
};
|
|
23
|
+
type AnchoredDocumentOffsetInput = {
|
|
24
|
+
viewportOffset: number;
|
|
25
|
+
startScrollOffset: number;
|
|
26
|
+
startContentLength: number;
|
|
27
|
+
endContentLength: number;
|
|
28
|
+
viewportLength: number;
|
|
29
|
+
};
|
|
30
|
+
type DocumentSurfaceWidthInput = {
|
|
31
|
+
viewportWidth: number;
|
|
32
|
+
contentWidth: number;
|
|
33
|
+
horizontalPadding: number;
|
|
34
|
+
};
|
|
35
|
+
type GlobalHorizontalOffsetInput = {
|
|
36
|
+
offsetX: number;
|
|
37
|
+
surfaceWidth: number;
|
|
38
|
+
viewportWidth: number;
|
|
39
|
+
};
|
|
40
|
+
type AnchoredHorizontalSurfaceOffsetInput = {
|
|
41
|
+
focalViewportX: number;
|
|
42
|
+
startSurfaceScrollX: number;
|
|
43
|
+
startSurfaceWidth: number;
|
|
44
|
+
endSurfaceWidth: number;
|
|
45
|
+
viewportWidth: number;
|
|
46
|
+
};
|
|
47
|
+
type CenteredContentInsetInput = {
|
|
48
|
+
viewportLength: number;
|
|
49
|
+
contentLength: number;
|
|
50
|
+
};
|
|
51
|
+
declare const DEFAULT_PINCH_ZOOM_BOUNDS: PinchZoomBounds;
|
|
52
|
+
declare const PINCH_PRESS_SUPPRESSION_MS = 120;
|
|
53
|
+
declare const getTouchDistance: (touches: PinchTouchPoint[]) => number;
|
|
54
|
+
declare const isPinchTouchList: (touches: PinchTouchPoint[]) => boolean;
|
|
55
|
+
declare const createPinchSession: (touches: PinchTouchPoint[], zoom: number, bounds?: PinchZoomBounds) => PinchSession;
|
|
56
|
+
declare const resolvePinchZoomChange: (session: PinchSession, touches: PinchTouchPoint[], bounds?: PinchZoomBounds) => number;
|
|
57
|
+
declare const resolvePinchPreviewScale: (startZoom: number, previewZoom: number) => number;
|
|
58
|
+
declare const sanitizePinchPreviewScale: (value: number) => number;
|
|
59
|
+
declare const resolvePinchGestureZoom: (startZoom: number, scaleFactor: number, bounds?: PinchZoomBounds) => number;
|
|
60
|
+
declare const resolveAnchoredViewportOffset: ({ viewportOffset, startScrollOffset, startItemOffset, startItemLength, endItemOffset, endItemLength, viewportLength, endContentLength, }: AnchoredViewportOffsetInput) => number;
|
|
61
|
+
declare const resolveAnchoredDocumentOffset: ({ viewportOffset, startScrollOffset, startContentLength, endContentLength, viewportLength, }: AnchoredDocumentOffsetInput) => number;
|
|
62
|
+
declare const resolveClampedScrollOffset: (offset: number, contentLength: number, viewportLength: number) => number;
|
|
63
|
+
declare const resolveDocumentSurfaceWidth: ({ viewportWidth, contentWidth, horizontalPadding, }: DocumentSurfaceWidthInput) => number;
|
|
64
|
+
declare const resolveGlobalHorizontalOffset: ({ offsetX, surfaceWidth, viewportWidth, }: GlobalHorizontalOffsetInput) => number;
|
|
65
|
+
declare const resolveAnchoredHorizontalSurfaceOffset: ({ focalViewportX, startSurfaceScrollX, startSurfaceWidth, endSurfaceWidth, viewportWidth, }: AnchoredHorizontalSurfaceOffsetInput) => number;
|
|
66
|
+
declare const resolveCenteredContentInset: ({ viewportLength, contentLength, }: CenteredContentInsetInput) => number;
|
|
67
|
+
declare const shouldSuppressPressAfterPinch: (lastPinchEndedAt: number | null | undefined, now?: number, windowMs?: number) => boolean;
|
|
68
|
+
|
|
69
|
+
export { type AnchoredDocumentOffsetInput, type AnchoredHorizontalSurfaceOffsetInput, type AnchoredViewportOffsetInput, type CenteredContentInsetInput, DEFAULT_PINCH_ZOOM_BOUNDS, type DocumentSurfaceWidthInput, type GlobalHorizontalOffsetInput, PINCH_PRESS_SUPPRESSION_MS, type PinchSession, type PinchTouchPoint, type PinchZoomBounds, createPinchSession, getTouchDistance, isPinchTouchList, resolveAnchoredDocumentOffset, resolveAnchoredHorizontalSurfaceOffset, resolveAnchoredViewportOffset, resolveCenteredContentInset, resolveClampedScrollOffset, resolveDocumentSurfaceWidth, resolveGlobalHorizontalOffset, resolvePinchGestureZoom, resolvePinchPreviewScale, resolvePinchZoomChange, sanitizePinchPreviewScale, shouldSuppressPressAfterPinch };
|