react-zoom-pan-pinch 4.3.0 → 4.4.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/index.cjs.js +335 -67
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +53 -3
- package/dist/index.esm.js +335 -68
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +40 -0
- package/package.json +1 -1
- package/src/components/transform-component/transform-component.tsx +25 -2
- package/src/constants/state.constants.ts +3 -0
- package/src/core/double-click/double-click.logic.ts +18 -9
- package/src/core/handlers/handlers.utils.ts +89 -2
- package/src/core/instance.core.ts +146 -24
- package/src/core/pan/panning.logic.ts +2 -1
- package/src/core/pan/panning.utils.ts +35 -0
- package/src/core/wheel/wheel.logic.ts +19 -2
- package/src/core/wheel/wheel.utils.ts +44 -2
- package/src/models/context.model.ts +25 -2
- package/src/typings.d.ts +5 -0
- package/src/utils/state.utils.ts +8 -2
- package/src/utils/styles.utils.ts +37 -0
package/dist/index.d.ts
CHANGED
|
@@ -109,6 +109,12 @@ declare class ZoomPanPinch {
|
|
|
109
109
|
x: number;
|
|
110
110
|
y: number;
|
|
111
111
|
} | null;
|
|
112
|
+
panGesture: {
|
|
113
|
+
startX: number;
|
|
114
|
+
startY: number;
|
|
115
|
+
hasMoved: boolean;
|
|
116
|
+
isDrag: boolean;
|
|
117
|
+
} | null;
|
|
112
118
|
lastTouch: number | null;
|
|
113
119
|
isPinching: boolean;
|
|
114
120
|
distance: null | number;
|
|
@@ -146,6 +152,7 @@ declare class ZoomPanPinch {
|
|
|
146
152
|
cleanupWindowEvents: () => void;
|
|
147
153
|
cleanupWrapperEvents: () => void;
|
|
148
154
|
handleInitializeWrapperEvents: (wrapper: HTMLDivElement) => void;
|
|
155
|
+
onWrapperScroll: () => void;
|
|
149
156
|
handleInitialize: () => void;
|
|
150
157
|
observeSizes: (wrapperComponent: HTMLDivElement, contentComponent: HTMLDivElement) => void;
|
|
151
158
|
onSizeChange: () => void;
|
|
@@ -155,6 +162,9 @@ declare class ZoomPanPinch {
|
|
|
155
162
|
onPanningStart: (event: MouseEvent) => void;
|
|
156
163
|
onPanning: (event: MouseEvent) => void;
|
|
157
164
|
onPanningStop: (event: MouseEvent | TouchEvent) => void;
|
|
165
|
+
startPanGesture: (clientX: number, clientY: number) => void;
|
|
166
|
+
trackPanGesture: (clientX: number, clientY: number) => boolean;
|
|
167
|
+
suppressNextClick: () => void;
|
|
158
168
|
onPinchStart: (event: TouchEvent) => void;
|
|
159
169
|
onPinch: (event: TouchEvent) => void;
|
|
160
170
|
onPinchStop: (event: TouchEvent) => void;
|
|
@@ -210,6 +220,8 @@ type ZoomToElementOptions = {
|
|
|
210
220
|
offsetY?: number;
|
|
211
221
|
};
|
|
212
222
|
type FitToViewMode = "contain" | "cover";
|
|
223
|
+
type InitialPositionX = number | "left" | "center" | "right";
|
|
224
|
+
type InitialPositionY = number | "top" | "center" | "bottom";
|
|
213
225
|
type FitToViewOptions = {
|
|
214
226
|
/** `contain` (default) shows the whole content, `cover` fills the viewport. */
|
|
215
227
|
mode?: FitToViewMode;
|
|
@@ -257,8 +269,14 @@ type ReactZoomPanPinchProps = {
|
|
|
257
269
|
ref?: React.Ref<ReactZoomPanPinchRef>;
|
|
258
270
|
detached?: boolean;
|
|
259
271
|
initialScale?: number;
|
|
260
|
-
|
|
261
|
-
|
|
272
|
+
/**
|
|
273
|
+
* Initial `positionX` in px, or where to place the content horizontally:
|
|
274
|
+
* `"left"`, `"center"` or `"right"` edge of the wrapper. A named position
|
|
275
|
+
* is resolved once the content has a size; `resetTransform` returns to it.
|
|
276
|
+
*/
|
|
277
|
+
initialPositionX?: InitialPositionX;
|
|
278
|
+
/** Like `initialPositionX`, with `"top"`, `"center"` or `"bottom"`. */
|
|
279
|
+
initialPositionY?: InitialPositionY;
|
|
262
280
|
disabled?: boolean;
|
|
263
281
|
minPositionX?: null | number;
|
|
264
282
|
maxPositionX?: null | number;
|
|
@@ -294,6 +312,18 @@ type ReactZoomPanPinchProps = {
|
|
|
294
312
|
allowLeftClickPan?: boolean;
|
|
295
313
|
allowMiddleClickPan?: boolean;
|
|
296
314
|
allowRightClickPan?: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Swallow the `click` that follows a mouse pan which moved the pointer
|
|
317
|
+
* more than 5px, so dragging over clickable content does not also click
|
|
318
|
+
* it. On by default.
|
|
319
|
+
*/
|
|
320
|
+
suppressClickAfterPan?: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Hand a gesture back to the page when its first move heads into a bound
|
|
323
|
+
* the content already rests on: no pan, no `preventDefault`, so the page
|
|
324
|
+
* scrolls or a parent carousel takes the drag. Off by default.
|
|
325
|
+
*/
|
|
326
|
+
releaseAtBounds?: boolean;
|
|
297
327
|
activationKeys?: string[] | ((keys: string[]) => boolean);
|
|
298
328
|
excluded?: string[];
|
|
299
329
|
};
|
|
@@ -306,6 +336,8 @@ type ReactZoomPanPinchProps = {
|
|
|
306
336
|
trackPadPanning?: {
|
|
307
337
|
disabled?: boolean;
|
|
308
338
|
velocityDisabled?: boolean;
|
|
339
|
+
/** Multiplier applied to the wheel/trackpad delta. Defaults to 1. */
|
|
340
|
+
speed?: number;
|
|
309
341
|
lockAxisX?: boolean;
|
|
310
342
|
lockAxisY?: boolean;
|
|
311
343
|
activationKeys?: string[] | ((keys: string[]) => boolean);
|
|
@@ -501,6 +533,16 @@ type Props = {
|
|
|
501
533
|
* `limitToBounds={false}` on TransformWrapper for full effect.
|
|
502
534
|
*/
|
|
503
535
|
infinite?: boolean;
|
|
536
|
+
/**
|
|
537
|
+
* Nonce for the `<style>` the component adds, for a Content Security
|
|
538
|
+
* Policy with `style-src 'nonce-…'`.
|
|
539
|
+
*/
|
|
540
|
+
nonce?: string;
|
|
541
|
+
/**
|
|
542
|
+
* Do not add the stylesheet; load `react-zoom-pan-pinch/dist/styles.css`
|
|
543
|
+
* yourself instead (a CSP that allows no inline `<style>`).
|
|
544
|
+
*/
|
|
545
|
+
disableStyleInjection?: boolean;
|
|
504
546
|
};
|
|
505
547
|
declare const TransformComponent: React.FC<Props>;
|
|
506
548
|
|
|
@@ -549,8 +591,16 @@ declare const Virtualize: React.ForwardRefExoticComponent<VirtualizeProps & Reac
|
|
|
549
591
|
|
|
550
592
|
/** Drop binary float noise on scale (e.g. 1.5000000000000002) without clipping real zoom values. */
|
|
551
593
|
declare const roundScaleForTransform: (scale: number) => number;
|
|
594
|
+
/**
|
|
595
|
+
* Adds the library stylesheet once per root the wrapper renders into: the
|
|
596
|
+
* document `<head>`, or the shadow root itself (#371), where a stylesheet in
|
|
597
|
+
* the head never applies. `nonce` is set on the `<style>` so a CSP with
|
|
598
|
+
* `style-src 'nonce-…'` accepts it (#403). A `<style>` already holding the
|
|
599
|
+
* same CSS is reused, so several viewers (or a re-mount) add one copy.
|
|
600
|
+
*/
|
|
601
|
+
declare function injectStylesheet(wrapper: HTMLElement, css: string | undefined, nonce?: string): void;
|
|
552
602
|
declare const getTransformStyles: (x: number, y: number, scale: number) => string;
|
|
553
603
|
declare const getMatrixTransformStyles: (x: number, y: number, scale: number) => string;
|
|
554
604
|
declare const getCenterPosition: (scale: number, wrapperComponent: HTMLDivElement, contentComponent: HTMLDivElement) => StateType;
|
|
555
605
|
|
|
556
|
-
export { type AnimationType, type BoundsType, Context, DeviceType, type FitToViewMode, type FitToViewOptions, KeepScale, type LibrarySetup, MiniMap, type MiniMapProps, type PositionType, type ReactZoomPanPinchBaseClasses, type ReactZoomPanPinchComponentHelpers, type ReactZoomPanPinchContentRef, type ReactZoomPanPinchContext, type ReactZoomPanPinchContextState, type ReactZoomPanPinchHandlers, type ReactZoomPanPinchProps, type ReactZoomPanPinchRef, type ReactZoomPanPinchRefProps, type ReactZoomPanPinchState, type SizeType, type StateType, TransformComponent, TransformWrapper, type VelocityType, Virtualize, type VirtualizeProps, type ZoomToElementOptions, type ZoomToElementTarget, getCenterPosition, getMatrixTransformStyles, getTransformStyles, roundScaleForTransform, useControls, useTransformComponent, useTransformContext, useTransformEffect, useTransformInit, useZoomPanPinch };
|
|
606
|
+
export { type AnimationType, type BoundsType, Context, DeviceType, type FitToViewMode, type FitToViewOptions, type InitialPositionX, type InitialPositionY, KeepScale, type LibrarySetup, MiniMap, type MiniMapProps, type PositionType, type ReactZoomPanPinchBaseClasses, type ReactZoomPanPinchComponentHelpers, type ReactZoomPanPinchContentRef, type ReactZoomPanPinchContext, type ReactZoomPanPinchContextState, type ReactZoomPanPinchHandlers, type ReactZoomPanPinchProps, type ReactZoomPanPinchRef, type ReactZoomPanPinchRefProps, type ReactZoomPanPinchState, type SizeType, type StateType, TransformComponent, TransformWrapper, type VelocityType, Virtualize, type VirtualizeProps, type ZoomToElementOptions, type ZoomToElementTarget, getCenterPosition, getMatrixTransformStyles, getTransformStyles, injectStylesheet, roundScaleForTransform, useControls, useTransformComponent, useTransformContext, useTransformEffect, useTransformInit, useZoomPanPinch };
|