react-zoom-pan-pinch 4.2.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.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
- initialPositionX?: number;
261
- initialPositionY?: number;
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);
@@ -443,17 +475,48 @@ declare const KeepScale: React.ForwardRefExoticComponent<React.HTMLAttributes<HT
443
475
 
444
476
  type MiniMapProps = {
445
477
  children: React.ReactNode;
478
+ /** Width of the mini map box in px. */
446
479
  width?: number;
480
+ /** Height of the mini map box in px. */
447
481
  height?: number;
482
+ /** Border colour of the viewport indicator. */
448
483
  borderColor?: string;
484
+ /**
485
+ * Colour of the overlay that dims everything outside the viewport
486
+ * (`.rzpp-minimap-mask`).
487
+ */
488
+ maskColor?: string;
449
489
  /** Merged onto the viewport indicator (`.rzpp-minimap-preview`). */
450
490
  previewStyle?: React.CSSProperties;
451
491
  /** Extra class name(s) appended to `.rzpp-minimap-wrapper`. */
452
492
  wrapperClassName?: string;
453
493
  /** Extra class name(s) appended to `.rzpp-minimap-preview`. */
454
494
  previewClassName?: string;
495
+ /**
496
+ * Dragging anywhere on the mini map grabs the viewport indicator and moves
497
+ * it with the pointer (mouse and touch).
498
+ */
455
499
  panning?: boolean;
456
- } & React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
500
+ /**
501
+ * Flips the drag direction: instead of grabbing the viewport indicator the
502
+ * drag moves the content, like panning the main view.
503
+ */
504
+ inversePan?: boolean;
505
+ /** Wheel over the mini map zooms the main view around its centre. */
506
+ zoomable?: boolean;
507
+ /** Scale increment applied per wheel notch when `zoomable` is on. */
508
+ zoomStep?: number;
509
+ /**
510
+ * Padding around the mapped area, in mini map px at the current map scale
511
+ * (same meaning as React Flow's `offsetScale`).
512
+ */
513
+ offsetScale?: number;
514
+ /**
515
+ * Fired for a click (or tap) that did not turn into a drag. `position` is
516
+ * the clicked point in content coordinates, ready for `zoomToPoint`.
517
+ */
518
+ onClick?: (event: MouseEvent | TouchEvent, position: PositionType) => void;
519
+ } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "onClick">;
457
520
  declare const MiniMap: React.FC<MiniMapProps>;
458
521
 
459
522
  type Props = {
@@ -470,6 +533,16 @@ type Props = {
470
533
  * `limitToBounds={false}` on TransformWrapper for full effect.
471
534
  */
472
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;
473
546
  };
474
547
  declare const TransformComponent: React.FC<Props>;
475
548
 
@@ -518,8 +591,16 @@ declare const Virtualize: React.ForwardRefExoticComponent<VirtualizeProps & Reac
518
591
 
519
592
  /** Drop binary float noise on scale (e.g. 1.5000000000000002) without clipping real zoom values. */
520
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;
521
602
  declare const getTransformStyles: (x: number, y: number, scale: number) => string;
522
603
  declare const getMatrixTransformStyles: (x: number, y: number, scale: number) => string;
523
604
  declare const getCenterPosition: (scale: number, wrapperComponent: HTMLDivElement, contentComponent: HTMLDivElement) => StateType;
524
605
 
525
- 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 };