react-zoom-pan-pinch 2.6.1 → 3.0.1
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/.eslintignore +6 -0
- package/.github/CODEOWNERS +36 -0
- package/.github/FUNDING.yml +13 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/workflows/docs.yml +34 -0
- package/.github/workflows/release.yml +46 -0
- package/.github/workflows/tests.yml +42 -0
- package/.prettierrc +10 -0
- package/.releaserc.json +63 -0
- package/CHANGELOG.md +12 -0
- package/Code_of_Conduct.md +61 -0
- package/Contributing.md +236 -0
- package/README.md +119 -88
- package/commitlint.config.js +1 -0
- package/dist/index.cjs.js +207 -36
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +100 -77
- package/dist/index.esm.js +204 -38
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/index.d.ts +4 -0
- package/dist/src/components/mini-map/mini-map.d.ts +7 -0
- package/dist/{components → src/components/transform-component}/transform-component.d.ts +1 -1
- package/dist/{components → src/components/transform-wrapper}/transform-wrapper.d.ts +3 -4
- package/dist/{core → src/core}/instance.core.d.ts +5 -0
- package/dist/src/hooks/index.d.ts +4 -0
- package/dist/src/hooks/use-controls.d.ts +2 -0
- package/dist/src/hooks/use-transform-context.d.ts +1 -0
- package/dist/src/hooks/use-transform-effect.d.ts +2 -0
- package/dist/src/hooks/use-transform-init.d.ts +2 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/{models → src/models}/context.model.d.ts +6 -2
- package/dist/src/utils/context.utils.d.ts +4 -0
- package/package.json +35 -15
- package/rollup.config.js +51 -0
- package/src/components/index.ts +4 -0
- package/src/components/{keep-scale.tsx → keep-scale/keep-scale.tsx} +2 -2
- package/src/components/mini-map/mini-map.tsx +155 -0
- package/src/components/{transform-component.tsx → transform-component/transform-component.tsx} +1 -3
- package/src/components/transform-wrapper/transform-wrapper.tsx +39 -0
- package/src/core/instance.core.ts +19 -3
- package/src/hooks/index.ts +4 -0
- package/src/hooks/use-controls.tsx +9 -0
- package/src/hooks/use-transform-context.tsx +4 -15
- package/src/hooks/use-transform-effect.tsx +22 -0
- package/src/hooks/use-transform-init.tsx +29 -0
- package/src/index.ts +2 -4
- package/src/models/context.model.ts +11 -2
- package/src/utils/context.utils.ts +24 -3
- package/tsconfig.json +32 -0
- package/dist/hooks/use-transform-context.d.ts +0 -3
- package/dist/stories/docs/handlers.d.ts +0 -12
- package/dist/stories/docs/props.d.ts +0 -14
- package/dist/stories/examples/content-rerendering/example.d.ts +0 -2
- package/dist/stories/examples/keep-scale/example.d.ts +0 -2
- package/dist/stories/examples/stress/example.d.ts +0 -2
- package/dist/stories/examples/svg-zoom-to-element/example.d.ts +0 -2
- package/dist/stories/examples/zoom-to-element/example.d.ts +0 -2
- package/dist/stories/types/args.types.d.ts +0 -268
- package/dist/stories/utils/args.utils.d.ts +0 -3
- package/dist/stories/utils/code.utils.d.ts +0 -6
- package/dist/stories/utils/controls.utils.d.ts +0 -3
- package/dist/stories/utils/index.d.ts +0 -3
- package/dist/utils/context.utils.d.ts +0 -2
- package/src/components/transform-wrapper.tsx +0 -56
- package/src/stories/assets/big-image.jpeg +0 -0
- package/src/stories/assets/map.jpg +0 -0
- package/src/stories/assets/medium-image.jpg +0 -0
- package/src/stories/assets/pin.svg +0 -1
- package/src/stories/assets/small-image.jpg +0 -0
- package/src/stories/assets/svg-example.svg +0 -14
- package/src/stories/docs/Introduction.stories.mdx +0 -97
- package/src/stories/docs/handlers.stories.mdx +0 -48
- package/src/stories/docs/handlers.tsx +0 -107
- package/src/stories/docs/props.stories.mdx +0 -92
- package/src/stories/docs/props.tsx +0 -496
- package/src/stories/examples/content/content.stories.mdx +0 -122
- package/src/stories/examples/content-rerendering/content-updating.stories.mdx +0 -45
- package/src/stories/examples/content-rerendering/example.tsx +0 -74
- package/src/stories/examples/controls/controls.stories.mdx +0 -72
- package/src/stories/examples/image-big/image-big.stories.mdx +0 -44
- package/src/stories/examples/image-medium/image-medium.stories.mdx +0 -42
- package/src/stories/examples/image-small/image-small.stories.mdx +0 -42
- package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +0 -47
- package/src/stories/examples/keep-scale/example.tsx +0 -94
- package/src/stories/examples/keep-scale/keep-scale.stories.mdx +0 -45
- package/src/stories/examples/stress/example.tsx +0 -24
- package/src/stories/examples/stress/stress-test.stories.mdx +0 -28
- package/src/stories/examples/svg-zoom-to-element/creativity.svg +0 -143
- package/src/stories/examples/svg-zoom-to-element/example.tsx +0 -57
- package/src/stories/examples/svg-zoom-to-element/svg-zoom-to-element.stories.mdx +0 -28
- package/src/stories/examples/zoom-to-element/example.tsx +0 -95
- package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +0 -28
- package/src/stories/types/args.types.ts +0 -201
- package/src/stories/utils/args.utils.ts +0 -34
- package/src/stories/utils/code.utils.tsx +0 -22
- package/src/stories/utils/controls.utils.tsx +0 -43
- package/src/stories/utils/index.ts +0 -3
- package/src/stories/utils/styles.module.css +0 -34
- /package/dist/{components → src/components/keep-scale}/keep-scale.d.ts +0 -0
- /package/dist/{constants → src/constants}/state.constants.d.ts +0 -0
- /package/dist/{core → src/core}/animations/animations.constants.d.ts +0 -0
- /package/dist/{core → src/core}/animations/animations.utils.d.ts +0 -0
- /package/dist/{core → src/core}/bounds/bounds.types.d.ts +0 -0
- /package/dist/{core → src/core}/bounds/bounds.utils.d.ts +0 -0
- /package/dist/{core → src/core}/double-click/double-click.logic.d.ts +0 -0
- /package/dist/{core → src/core}/handlers/handlers.logic.d.ts +0 -0
- /package/dist/{core → src/core}/handlers/handlers.utils.d.ts +0 -0
- /package/dist/{core → src/core}/pan/panning.logic.d.ts +0 -0
- /package/dist/{core → src/core}/pan/panning.utils.d.ts +0 -0
- /package/dist/{core → src/core}/pan/velocity.logic.d.ts +0 -0
- /package/dist/{core → src/core}/pan/velocity.utils.d.ts +0 -0
- /package/dist/{core → src/core}/pinch/pinch.logic.d.ts +0 -0
- /package/dist/{core → src/core}/pinch/pinch.utils.d.ts +0 -0
- /package/dist/{core → src/core}/wheel/wheel.logic.d.ts +0 -0
- /package/dist/{core → src/core}/wheel/wheel.utils.d.ts +0 -0
- /package/dist/{core → src/core}/zoom/zoom.logic.d.ts +0 -0
- /package/dist/{core → src/core}/zoom/zoom.utils.d.ts +0 -0
- /package/dist/{models → src/models}/calculations.model.d.ts +0 -0
- /package/dist/{models → src/models}/helpers.model.d.ts +0 -0
- /package/dist/{models → src/models}/index.d.ts +0 -0
- /package/dist/{utils → src/utils}/calculations.utils.d.ts +0 -0
- /package/dist/{utils → src/utils}/callback.utils.d.ts +0 -0
- /package/dist/{utils → src/utils}/event.utils.d.ts +0 -0
- /package/dist/{utils → src/utils}/helpers.utils.d.ts +0 -0
- /package/dist/{utils → src/utils}/index.d.ts +0 -0
- /package/dist/{utils → src/utils}/ref.utils.d.ts +0 -0
- /package/dist/{utils → src/utils}/state.utils.d.ts +0 -0
- /package/dist/{utils → src/utils}/styles.utils.d.ts +0 -0
- /package/src/components/{transform-component.module.css → transform-component/transform-component.module.css} +0 -0
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export const normalizeArgs = (args: { [key: string]: any }): any => {
|
|
2
|
-
const newArgs = {};
|
|
3
|
-
|
|
4
|
-
Object.keys(args).forEach((key) => {
|
|
5
|
-
const normalizedKey = key.split(".");
|
|
6
|
-
const isNested = normalizedKey.length === 2;
|
|
7
|
-
|
|
8
|
-
if (isNested) {
|
|
9
|
-
if (!newArgs[normalizedKey[0]]) {
|
|
10
|
-
newArgs[normalizedKey[0]] = {};
|
|
11
|
-
}
|
|
12
|
-
newArgs[normalizedKey[0]][normalizedKey[1]] = args[key];
|
|
13
|
-
} else {
|
|
14
|
-
newArgs[key] = args[key];
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
...newArgs,
|
|
20
|
-
onTransformed: undefined,
|
|
21
|
-
onWheelStart: undefined,
|
|
22
|
-
onWheel: undefined,
|
|
23
|
-
onWheelStop: undefined,
|
|
24
|
-
onZoomStart: undefined,
|
|
25
|
-
onZoom: undefined,
|
|
26
|
-
onZoomStop: undefined,
|
|
27
|
-
onPanningStart: undefined,
|
|
28
|
-
onPanning: undefined,
|
|
29
|
-
onPanningStop: undefined,
|
|
30
|
-
onPinchStart: undefined,
|
|
31
|
-
onPinch: undefined,
|
|
32
|
-
onPinchStop: undefined,
|
|
33
|
-
};
|
|
34
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/no-array-index-key */
|
|
2
|
-
import React from "react";
|
|
3
|
-
import Highlight, { defaultProps } from "prism-react-renderer";
|
|
4
|
-
import vsLight from "prism-react-renderer/themes/vsLight";
|
|
5
|
-
|
|
6
|
-
type Props = { code: string };
|
|
7
|
-
|
|
8
|
-
export const Code: React.FC<Props> = ({ code }: Props) => (
|
|
9
|
-
<Highlight {...defaultProps} code={code} theme={vsLight} language="tsx">
|
|
10
|
-
{({ className, style, tokens, getLineProps, getTokenProps }) => (
|
|
11
|
-
<pre className={className} style={style}>
|
|
12
|
-
{tokens.map((line, i) => (
|
|
13
|
-
<div key={i} {...getLineProps({ line, key: i })}>
|
|
14
|
-
{line.map((token, key) => (
|
|
15
|
-
<span key={key} {...getTokenProps({ token, key })} />
|
|
16
|
-
))}
|
|
17
|
-
</div>
|
|
18
|
-
))}
|
|
19
|
-
</pre>
|
|
20
|
-
)}
|
|
21
|
-
</Highlight>
|
|
22
|
-
);
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { ReactZoomPanPinchRef } from "../../models/context.model";
|
|
4
|
-
|
|
5
|
-
import styles from "./styles.module.css";
|
|
6
|
-
|
|
7
|
-
export const Controls: React.FC<ReactZoomPanPinchRef> = ({
|
|
8
|
-
zoomIn,
|
|
9
|
-
zoomOut,
|
|
10
|
-
resetTransform,
|
|
11
|
-
centerView,
|
|
12
|
-
}: ReactZoomPanPinchRef) => (
|
|
13
|
-
<div className={styles.controlPanel}>
|
|
14
|
-
<button
|
|
15
|
-
type="button"
|
|
16
|
-
className={styles.controlBtn}
|
|
17
|
-
onClick={() => zoomIn()}
|
|
18
|
-
>
|
|
19
|
-
Zoom In +
|
|
20
|
-
</button>
|
|
21
|
-
<button
|
|
22
|
-
type="button"
|
|
23
|
-
className={styles.controlBtn}
|
|
24
|
-
onClick={() => zoomOut()}
|
|
25
|
-
>
|
|
26
|
-
Zoom Out -
|
|
27
|
-
</button>
|
|
28
|
-
<button
|
|
29
|
-
type="button"
|
|
30
|
-
className={styles.controlBtn}
|
|
31
|
-
onClick={() => resetTransform()}
|
|
32
|
-
>
|
|
33
|
-
Reset
|
|
34
|
-
</button>
|
|
35
|
-
<button
|
|
36
|
-
type="button"
|
|
37
|
-
className={styles.controlBtn}
|
|
38
|
-
onClick={() => centerView()}
|
|
39
|
-
>
|
|
40
|
-
Center
|
|
41
|
-
</button>
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
.controlPanel {
|
|
2
|
-
position: absolute;
|
|
3
|
-
z-index: 2;
|
|
4
|
-
transform: translate(10px, 10px);
|
|
5
|
-
max-width: calc(100% - 20px);
|
|
6
|
-
}
|
|
7
|
-
.controlBtn {
|
|
8
|
-
padding: 6px 12px;
|
|
9
|
-
background: white;
|
|
10
|
-
border: 1px solid grey;
|
|
11
|
-
border-radius: 5px;
|
|
12
|
-
margin-right: 10px;
|
|
13
|
-
font-size: 12px;
|
|
14
|
-
text-transform: uppercase;
|
|
15
|
-
font-weight: 600;
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.controlBtn:focus {
|
|
20
|
-
filter: brightness(90%);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.controlBtn:hover {
|
|
24
|
-
filter: brightness(120%);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.controlBtn:active {
|
|
28
|
-
opacity: 0.9;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.grid {
|
|
32
|
-
display: grid;
|
|
33
|
-
grid-template-columns: repeat(100, 1fr);
|
|
34
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|