react-zoom-pan-pinch 2.3.1 → 2.3.2

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.
@@ -6,6 +6,7 @@ import {
6
6
  AnimationType,
7
7
  ReactZoomPanPinchProps,
8
8
  ReactZoomPanPinchState,
9
+ ReactZoomPanPinchRef,
9
10
  } from "../models";
10
11
  import {
11
12
  getContext,
@@ -83,7 +84,10 @@ export class ZoomPanPinch {
83
84
  // key press
84
85
  public pressedKeys: { [key: string]: boolean } = {};
85
86
 
86
- constructor(props: ReactZoomPanPinchProps) {
87
+ constructor(
88
+ props: ReactZoomPanPinchProps,
89
+ private onChange?: (ctx: ReactZoomPanPinchRef) => void,
90
+ ) {
87
91
  this.props = props;
88
92
  this.setup = createSetup(this.props);
89
93
  this.transformState = createState(this.props);
@@ -405,11 +409,10 @@ export class ZoomPanPinch {
405
409
  this.transformState.positionX = positionX;
406
410
  this.transformState.positionY = positionY;
407
411
 
408
- handleCallback(
409
- getContext(this),
410
- { scale, positionX, positionY },
411
- onTransformed,
412
- );
412
+ const ctx = getContext(this);
413
+ this.onChange?.(ctx);
414
+
415
+ handleCallback(ctx, { scale, positionX, positionY }, onTransformed);
413
416
  this.applyTransformation();
414
417
  } else {
415
418
  console.error("Detected NaN set state values");
@@ -42,6 +42,7 @@ export type ReactZoomPanPinchRefProps = {
42
42
  export type ReactZoomPanPinchProps = {
43
43
  children?: React.ReactNode | ((ref: ReactZoomPanPinchRef) => React.ReactNode);
44
44
  ref?: React.Ref<ReactZoomPanPinchRef>;
45
+ performance?: boolean;
45
46
  initialScale?: number;
46
47
  initialPositionX?: number;
47
48
  initialPositionY?: number;
@@ -101,6 +101,12 @@ export const wrapperPropsTable: ComponentProps = {
101
101
  description:
102
102
  "This is 'global' disable props. Setting it as a 'true' value blocks all functionalities of library. For disabling parts of it like panning, zooming, pinch - checkout the dedicated sections below.",
103
103
  },
104
+ performance: {
105
+ type: ["boolean"],
106
+ defaultValue: String(initialSetup.performance),
107
+ description:
108
+ "Enable this prop to switch to limited rendering performance mode",
109
+ },
104
110
  minPositionX: {
105
111
  type: ["number"],
106
112
  defaultValue: String(initialSetup.minPositionX),