react-zoom-pan-pinch 2.5.1 → 2.6.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/core/instance.core.d.ts +1 -0
- package/dist/index.cjs.js +51 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.esm.js +48 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/models/context.model.d.ts +2 -1
- package/dist/utils/styles.utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/keep-scale.tsx +1 -2
- package/src/core/instance.core.ts +8 -1
- package/src/index.ts +2 -0
- package/src/models/context.model.ts +2 -0
- package/src/stories/docs/props.tsx +6 -0
- package/src/stories/examples/keep-scale/example.tsx +3 -3
- package/src/utils/styles.utils.ts +17 -1
|
@@ -159,6 +159,12 @@ export const wrapperPropsTable: ComponentProps = {
|
|
|
159
159
|
description:
|
|
160
160
|
"Used to disable panning, zooming boundary padding effect. By enabling this option, you will not be able to zoom outside the image area.",
|
|
161
161
|
},
|
|
162
|
+
customTransform: {
|
|
163
|
+
type: ["function"],
|
|
164
|
+
defaultValue: "undefined",
|
|
165
|
+
description:
|
|
166
|
+
"We can provide custom transform function to provide different way of handling our transform logic. If we need performance we can import getMatrixTransformStyles functions and replace default one. WARNING: default transform prevents svg blur on the safari.",
|
|
167
|
+
},
|
|
162
168
|
wheel: {
|
|
163
169
|
wheel: {
|
|
164
170
|
type: [""],
|
|
@@ -9,10 +9,10 @@ import { ReactComponent as Pin } from "../../assets/pin.svg";
|
|
|
9
9
|
|
|
10
10
|
export const Example: React.FC<any> = (args: any) => {
|
|
11
11
|
return (
|
|
12
|
-
<TransformWrapper {...normalizeArgs(args)}>
|
|
12
|
+
<TransformWrapper {...normalizeArgs(args)} maxScale={100}>
|
|
13
13
|
<TransformComponent
|
|
14
14
|
wrapperStyle={{
|
|
15
|
-
width: "
|
|
15
|
+
width: "700px",
|
|
16
16
|
height: "500px",
|
|
17
17
|
maxWidth: "100%",
|
|
18
18
|
maxHeight: "calc(100vh - 50px)",
|
|
@@ -24,7 +24,7 @@ export const Example: React.FC<any> = (args: any) => {
|
|
|
24
24
|
background: "#999",
|
|
25
25
|
}}
|
|
26
26
|
>
|
|
27
|
-
<h2>Pins will keep the initial scale</h2>
|
|
27
|
+
<h2>Pins will keep the initial scale with KeepScale component</h2>
|
|
28
28
|
|
|
29
29
|
<img
|
|
30
30
|
style={{ width: "600px", height: "300px" }}
|
|
@@ -6,7 +6,23 @@ export const getTransformStyles = (
|
|
|
6
6
|
scale: number,
|
|
7
7
|
): string => {
|
|
8
8
|
// Standard translate prevents blurry svg on the safari
|
|
9
|
-
return `
|
|
9
|
+
return `translate3d(${x}px, ${y}px, 0) scale(${scale})`;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const getMatrixTransformStyles = (
|
|
13
|
+
x: number,
|
|
14
|
+
y: number,
|
|
15
|
+
scale: number,
|
|
16
|
+
): string => {
|
|
17
|
+
// The shorthand for matrix does not work for Safari hence the need to explicitly use matrix3d
|
|
18
|
+
// Refer to https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix
|
|
19
|
+
const a = scale;
|
|
20
|
+
const b = 0;
|
|
21
|
+
const c = 0;
|
|
22
|
+
const d = scale;
|
|
23
|
+
const tx = x;
|
|
24
|
+
const ty = y;
|
|
25
|
+
return `matrix3d(${a}, ${b}, 0, 0, ${c}, ${d}, 0, 0, 0, 0, 1, 0, ${tx}, ${ty}, 0, 1)`;
|
|
10
26
|
};
|
|
11
27
|
|
|
12
28
|
export const getCenterPosition = (
|