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.
- package/dist/components/transform-component.d.ts +2 -0
- package/dist/core/instance.core.d.ts +4 -3
- package/dist/index.cjs.js +18 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.esm.js +19 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/models/context.model.d.ts +1 -0
- package/package.json +3 -2
- package/src/components/transform-component.tsx +7 -0
- package/src/components/transform-wrapper.tsx +16 -3
- package/src/constants/state.constants.ts +1 -0
- package/src/core/instance.core.ts +9 -6
- package/src/models/context.model.ts +1 -0
- package/src/stories/docs/props.tsx +6 -0
|
@@ -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(
|
|
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
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
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),
|