react-zoom-pan-pinch 2.6.1 → 3.0.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/.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 +27 -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 +206 -35
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +100 -77
- package/dist/index.esm.js +203 -37
- 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 +18 -1
- 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,122 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, ArgsTable, Canvas } from "@storybook/addon-docs/blocks";
|
|
2
|
-
import { action } from "@storybook/addon-actions";
|
|
3
|
-
|
|
4
|
-
import { TransformWrapper } from "../../../components/transform-wrapper";
|
|
5
|
-
import { TransformComponent } from "../../../components/transform-component";
|
|
6
|
-
import { argsTypes } from "../../types/args.types.ts";
|
|
7
|
-
import { normalizeArgs } from "../../utils";
|
|
8
|
-
|
|
9
|
-
import exampleImg from "../../assets/small-image.jpg";
|
|
10
|
-
|
|
11
|
-
export const Template = (args) => (
|
|
12
|
-
<TransformWrapper {...normalizeArgs(args)}>
|
|
13
|
-
<TransformComponent
|
|
14
|
-
wrapperStyle={{ maxWidth: "100%", maxHeight: "calc(100vh - 50px)" }}
|
|
15
|
-
>
|
|
16
|
-
<div style={{ background: "#444", color: "white", padding: "50px" }}>
|
|
17
|
-
<h1>No scrollbars needed</h1>
|
|
18
|
-
<h2>Use mouse or gestures to move around</h2>
|
|
19
|
-
<button
|
|
20
|
-
onClick={() => alert("You can still interact with click events!")}
|
|
21
|
-
>
|
|
22
|
-
Click me!
|
|
23
|
-
</button>
|
|
24
|
-
<div
|
|
25
|
-
style={{
|
|
26
|
-
display: "flex",
|
|
27
|
-
overflow: "auto",
|
|
28
|
-
maxWidth: "100%",
|
|
29
|
-
padding: "10px",
|
|
30
|
-
}}
|
|
31
|
-
>
|
|
32
|
-
<div
|
|
33
|
-
style={{
|
|
34
|
-
width: "100px",
|
|
35
|
-
height: "100px",
|
|
36
|
-
padding: "10px",
|
|
37
|
-
background: "red",
|
|
38
|
-
}}
|
|
39
|
-
className="panningDisabled"
|
|
40
|
-
>
|
|
41
|
-
Panning is DISABLED on this element
|
|
42
|
-
</div>
|
|
43
|
-
<div
|
|
44
|
-
style={{
|
|
45
|
-
width: "100px",
|
|
46
|
-
height: "100px",
|
|
47
|
-
padding: "10px",
|
|
48
|
-
background: "blue",
|
|
49
|
-
}}
|
|
50
|
-
className="wheelDisabled"
|
|
51
|
-
>
|
|
52
|
-
Wheel is DISABLED on this element
|
|
53
|
-
</div>
|
|
54
|
-
<div
|
|
55
|
-
style={{
|
|
56
|
-
width: "100px",
|
|
57
|
-
height: "100px",
|
|
58
|
-
padding: "10px",
|
|
59
|
-
background: "green",
|
|
60
|
-
}}
|
|
61
|
-
className="pinchDisabled"
|
|
62
|
-
>
|
|
63
|
-
Pinch is DISABLED on this element
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
<p>
|
|
67
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
68
|
-
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
|
|
69
|
-
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
|
|
70
|
-
aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
71
|
-
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
72
|
-
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
73
|
-
culpa qui officia deserunt mollit anim id est laborum
|
|
74
|
-
</p>
|
|
75
|
-
<img src={exampleImg} alt="" />
|
|
76
|
-
<p>
|
|
77
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
78
|
-
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
|
|
79
|
-
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
|
|
80
|
-
aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
81
|
-
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
82
|
-
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
83
|
-
culpa qui officia deserunt mollit anim id est laborum
|
|
84
|
-
</p>
|
|
85
|
-
</div>
|
|
86
|
-
</TransformComponent>
|
|
87
|
-
</TransformWrapper>
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
<Meta
|
|
91
|
-
title="Examples/Mixed Content"
|
|
92
|
-
component={TransformWrapper}
|
|
93
|
-
argTypes={{
|
|
94
|
-
...argsTypes,
|
|
95
|
-
"wheel.excluded": {
|
|
96
|
-
...argsTypes["wheel.excluded"],
|
|
97
|
-
defaultValue: ["wheelDisabled"],
|
|
98
|
-
},
|
|
99
|
-
"panning.excluded": {
|
|
100
|
-
...argsTypes["panning.excluded"],
|
|
101
|
-
defaultValue: ["panningDisabled"],
|
|
102
|
-
},
|
|
103
|
-
"pinch.excluded": {
|
|
104
|
-
...argsTypes["pinch.excluded"],
|
|
105
|
-
defaultValue: ["pinchDisabled"],
|
|
106
|
-
},
|
|
107
|
-
}}
|
|
108
|
-
/>
|
|
109
|
-
|
|
110
|
-
# Mixed Content
|
|
111
|
-
|
|
112
|
-
<br />
|
|
113
|
-
|
|
114
|
-
### Preview:
|
|
115
|
-
|
|
116
|
-
<Canvas>
|
|
117
|
-
<Story name="Mixed Content">{(args) => <Template {...args} />}</Story>
|
|
118
|
-
</Canvas>
|
|
119
|
-
|
|
120
|
-
## Component API
|
|
121
|
-
|
|
122
|
-
<ArgsTable story="Mixed Content" />
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, ArgsTable, Canvas } from "@storybook/addon-docs/blocks";
|
|
2
|
-
import { action } from "@storybook/addon-actions";
|
|
3
|
-
|
|
4
|
-
import { TransformWrapper } from "../../../components/transform-wrapper";
|
|
5
|
-
import { argsTypes } from "../../types/args.types";
|
|
6
|
-
import { Example } from "./example";
|
|
7
|
-
|
|
8
|
-
export const Template = (args) => <Example {...args} />;
|
|
9
|
-
|
|
10
|
-
<Meta
|
|
11
|
-
title="Examples/Rerendering content"
|
|
12
|
-
component={TransformWrapper}
|
|
13
|
-
argTypes={{
|
|
14
|
-
...argsTypes,
|
|
15
|
-
"wheel.excluded": {
|
|
16
|
-
...argsTypes["wheel.excluded"],
|
|
17
|
-
defaultValue: ["wheelDisabled"],
|
|
18
|
-
},
|
|
19
|
-
"panning.excluded": {
|
|
20
|
-
...argsTypes["panning.excluded"],
|
|
21
|
-
defaultValue: ["panningDisabled"],
|
|
22
|
-
},
|
|
23
|
-
"pinch.excluded": {
|
|
24
|
-
...argsTypes["pinch.excluded"],
|
|
25
|
-
defaultValue: ["pinchDisabled"],
|
|
26
|
-
},
|
|
27
|
-
centerOnInit: {
|
|
28
|
-
defaultValue: true,
|
|
29
|
-
},
|
|
30
|
-
}}
|
|
31
|
-
/>
|
|
32
|
-
|
|
33
|
-
# Rerendering content
|
|
34
|
-
|
|
35
|
-
<br />
|
|
36
|
-
|
|
37
|
-
### Preview:
|
|
38
|
-
|
|
39
|
-
<Canvas>
|
|
40
|
-
<Story name="Rerendering content">{(args) => <Template {...args} />}</Story>
|
|
41
|
-
</Canvas>
|
|
42
|
-
|
|
43
|
-
## Component API
|
|
44
|
-
|
|
45
|
-
<ArgsTable story="Rerendering content" />
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import { TransformWrapper } from "../../../components/transform-wrapper";
|
|
4
|
-
import { TransformComponent } from "../../../components/transform-component";
|
|
5
|
-
import { normalizeArgs } from "../../utils";
|
|
6
|
-
|
|
7
|
-
export const Example: React.FC<any> = (args: any) => {
|
|
8
|
-
const [firstBlock, setFirstBlock] = useState(false);
|
|
9
|
-
const [secondBlock, setSecondBlock] = useState(false);
|
|
10
|
-
const [thirdBlock, setThirdBlock] = useState(false);
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const a = setInterval(() => {
|
|
14
|
-
setFirstBlock((prev) => !prev);
|
|
15
|
-
}, 1000);
|
|
16
|
-
const b = setInterval(() => {
|
|
17
|
-
setSecondBlock((prev) => !prev);
|
|
18
|
-
}, 3000);
|
|
19
|
-
const c = setInterval(() => {
|
|
20
|
-
setThirdBlock((prev) => !prev);
|
|
21
|
-
}, 12000);
|
|
22
|
-
return () => {
|
|
23
|
-
clearInterval(a);
|
|
24
|
-
clearInterval(b);
|
|
25
|
-
clearInterval(c);
|
|
26
|
-
};
|
|
27
|
-
}, []);
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<TransformWrapper {...normalizeArgs(args)}>
|
|
31
|
-
<TransformComponent
|
|
32
|
-
wrapperStyle={{
|
|
33
|
-
width: "500px",
|
|
34
|
-
height: "500px",
|
|
35
|
-
maxWidth: "100%",
|
|
36
|
-
maxHeight: "calc(100vh - 50px)",
|
|
37
|
-
}}
|
|
38
|
-
>
|
|
39
|
-
<div
|
|
40
|
-
style={{
|
|
41
|
-
background: "#444",
|
|
42
|
-
color: "white",
|
|
43
|
-
padding: "50px",
|
|
44
|
-
minHeight: "300px",
|
|
45
|
-
width: "100%",
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
<h2>Constantly rerendering content</h2>
|
|
49
|
-
|
|
50
|
-
{firstBlock ? <p>Content #1</p> : <p>Changed Content #1</p>}
|
|
51
|
-
|
|
52
|
-
{secondBlock ? <p>Content #2</p> : <p>Changed Content #2</p>}
|
|
53
|
-
|
|
54
|
-
{thirdBlock ? (
|
|
55
|
-
<p>Content #3</p>
|
|
56
|
-
) : (
|
|
57
|
-
<p>
|
|
58
|
-
Changed Content #3
|
|
59
|
-
<br />
|
|
60
|
-
<br />
|
|
61
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
62
|
-
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
|
|
63
|
-
enim ad minim veniam, quis nostrud exercitation ullamco laboris
|
|
64
|
-
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
65
|
-
reprehenderit in voluptate velit esse cillum dolore eu fugiat
|
|
66
|
-
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
|
|
67
|
-
sunt in culpa qui officia deserunt mollit anim id est laborum
|
|
68
|
-
</p>
|
|
69
|
-
)}
|
|
70
|
-
</div>
|
|
71
|
-
</TransformComponent>
|
|
72
|
-
</TransformWrapper>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, ArgsTable, Canvas } from "@storybook/addon-docs/blocks";
|
|
2
|
-
import { action } from "@storybook/addon-actions";
|
|
3
|
-
|
|
4
|
-
import { TransformWrapper } from "../../../components/transform-wrapper";
|
|
5
|
-
import { TransformComponent } from "../../../components/transform-component";
|
|
6
|
-
import { argsTypes } from "../../types/args.types.ts";
|
|
7
|
-
import { normalizeArgs, Controls } from "../../utils";
|
|
8
|
-
|
|
9
|
-
import exampleImg from "../../assets/small-image.jpg";
|
|
10
|
-
|
|
11
|
-
export const Template = (args) => (
|
|
12
|
-
<TransformWrapper {...normalizeArgs(args)}>
|
|
13
|
-
{(utils) => (
|
|
14
|
-
<div>
|
|
15
|
-
<Controls {...utils} />
|
|
16
|
-
<TransformComponent
|
|
17
|
-
wrapperStyle={{ maxWidth: "100%", maxHeight: "calc(100vh - 50px)" }}
|
|
18
|
-
>
|
|
19
|
-
<div style={{ background: "#444", color: "white", padding: "50px" }}>
|
|
20
|
-
{JSON.stringify(utils.state, null, 4)}
|
|
21
|
-
<h1>No scrollbars needed</h1>
|
|
22
|
-
<h2>Use mouse or gestures to move around</h2>
|
|
23
|
-
<button
|
|
24
|
-
onClick={() => alert("You can still interact with click events!")}
|
|
25
|
-
>
|
|
26
|
-
Click me!
|
|
27
|
-
</button>
|
|
28
|
-
<p>
|
|
29
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
30
|
-
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
|
|
31
|
-
enim ad minim veniam, quis nostrud exercitation ullamco laboris
|
|
32
|
-
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
33
|
-
reprehenderit in voluptate velit esse cillum dolore eu fugiat
|
|
34
|
-
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
|
|
35
|
-
sunt in culpa qui officia deserunt mollit anim id est laborum
|
|
36
|
-
</p>
|
|
37
|
-
<img src={exampleImg} alt="" />
|
|
38
|
-
<p>
|
|
39
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
40
|
-
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
|
|
41
|
-
enim ad minim veniam, quis nostrud exercitation ullamco laboris
|
|
42
|
-
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
43
|
-
reprehenderit in voluptate velit esse cillum dolore eu fugiat
|
|
44
|
-
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
|
|
45
|
-
sunt in culpa qui officia deserunt mollit anim id est laborum
|
|
46
|
-
</p>
|
|
47
|
-
</div>
|
|
48
|
-
</TransformComponent>
|
|
49
|
-
</div>
|
|
50
|
-
)}
|
|
51
|
-
</TransformWrapper>
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
<Meta
|
|
55
|
-
title="Examples/Controls"
|
|
56
|
-
component={TransformWrapper}
|
|
57
|
-
argTypes={argsTypes}
|
|
58
|
-
/>
|
|
59
|
-
|
|
60
|
-
# Controls
|
|
61
|
-
|
|
62
|
-
<br />
|
|
63
|
-
|
|
64
|
-
### Preview:
|
|
65
|
-
|
|
66
|
-
<Canvas>
|
|
67
|
-
<Story name="Controls">{(args) => <Template {...args} />}</Story>
|
|
68
|
-
</Canvas>
|
|
69
|
-
|
|
70
|
-
## Component API
|
|
71
|
-
|
|
72
|
-
<ArgsTable story="Controls" />
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, ArgsTable, Canvas } from "@storybook/addon-docs/blocks";
|
|
2
|
-
import { action } from "@storybook/addon-actions";
|
|
3
|
-
|
|
4
|
-
import { TransformWrapper } from "../../../components/transform-wrapper";
|
|
5
|
-
import { TransformComponent } from "../../../components/transform-component";
|
|
6
|
-
import { argsTypes } from "../../types/args.types.ts";
|
|
7
|
-
import { normalizeArgs, Controls } from "../../utils";
|
|
8
|
-
|
|
9
|
-
import exampleImg from "../../assets/big-image.jpeg";
|
|
10
|
-
|
|
11
|
-
export const Template = (args) => (
|
|
12
|
-
<TransformWrapper {...normalizeArgs(args)}>
|
|
13
|
-
{(utils) => (
|
|
14
|
-
<div>
|
|
15
|
-
<Controls {...utils} />
|
|
16
|
-
<TransformComponent
|
|
17
|
-
wrapperStyle={{ maxWidth: "100%", maxHeight: "calc(100vh - 50px)" }}
|
|
18
|
-
>
|
|
19
|
-
<img src={exampleImg} alt="" />
|
|
20
|
-
</TransformComponent>
|
|
21
|
-
</div>
|
|
22
|
-
)}
|
|
23
|
-
</TransformWrapper>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
<Meta
|
|
27
|
-
title="Examples/Big Image"
|
|
28
|
-
component={TransformWrapper}
|
|
29
|
-
argTypes={argsTypes}
|
|
30
|
-
/>
|
|
31
|
-
|
|
32
|
-
# Big Image
|
|
33
|
-
|
|
34
|
-
<br />
|
|
35
|
-
|
|
36
|
-
### Preview:
|
|
37
|
-
|
|
38
|
-
<Canvas>
|
|
39
|
-
<Story name="Big Image">{(args) => <Template {...args} />}</Story>
|
|
40
|
-
</Canvas>
|
|
41
|
-
|
|
42
|
-
## Component API
|
|
43
|
-
|
|
44
|
-
<ArgsTable story="Big Image" />
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, ArgsTable, Canvas } from "@storybook/addon-docs/blocks";
|
|
2
|
-
import { action } from "@storybook/addon-actions";
|
|
3
|
-
|
|
4
|
-
import { TransformWrapper } from "../../../components/transform-wrapper";
|
|
5
|
-
import { TransformComponent } from "../../../components/transform-component";
|
|
6
|
-
import { argsTypes } from "../../types/args.types.ts";
|
|
7
|
-
import { normalizeArgs, Controls } from "../../utils";
|
|
8
|
-
|
|
9
|
-
import exampleImg from "../../assets/medium-image.jpg";
|
|
10
|
-
|
|
11
|
-
export const Template = (args) => (
|
|
12
|
-
<TransformWrapper {...normalizeArgs(args)}>
|
|
13
|
-
{(utils) => (
|
|
14
|
-
<div>
|
|
15
|
-
<Controls {...utils} />
|
|
16
|
-
<TransformComponent>
|
|
17
|
-
<img src={exampleImg} alt="" />
|
|
18
|
-
</TransformComponent>
|
|
19
|
-
</div>
|
|
20
|
-
)}
|
|
21
|
-
</TransformWrapper>
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
<Meta
|
|
25
|
-
title="Examples/Medium Image"
|
|
26
|
-
component={TransformWrapper}
|
|
27
|
-
argTypes={argsTypes}
|
|
28
|
-
/>
|
|
29
|
-
|
|
30
|
-
# Medium Image
|
|
31
|
-
|
|
32
|
-
<br />
|
|
33
|
-
|
|
34
|
-
### Preview:
|
|
35
|
-
|
|
36
|
-
<Canvas>
|
|
37
|
-
<Story name="Medium Image">{(args) => <Template {...args} />}</Story>
|
|
38
|
-
</Canvas>
|
|
39
|
-
|
|
40
|
-
## Component API
|
|
41
|
-
|
|
42
|
-
<ArgsTable story="Medium Image" />
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, ArgsTable, Canvas } from "@storybook/addon-docs/blocks";
|
|
2
|
-
import { action } from "@storybook/addon-actions";
|
|
3
|
-
|
|
4
|
-
import { TransformWrapper } from "../../../components/transform-wrapper";
|
|
5
|
-
import { TransformComponent } from "../../../components/transform-component";
|
|
6
|
-
import { argsTypes } from "../../types/args.types.ts";
|
|
7
|
-
import { normalizeArgs, Controls } from "../../utils";
|
|
8
|
-
|
|
9
|
-
import exampleImg from "../../assets/small-image.jpg";
|
|
10
|
-
|
|
11
|
-
export const Template = (args) => (
|
|
12
|
-
<TransformWrapper {...normalizeArgs(args)}>
|
|
13
|
-
{(utils) => (
|
|
14
|
-
<div>
|
|
15
|
-
<Controls {...utils} />
|
|
16
|
-
<TransformComponent>
|
|
17
|
-
<img src={exampleImg} alt="" />
|
|
18
|
-
</TransformComponent>
|
|
19
|
-
</div>
|
|
20
|
-
)}
|
|
21
|
-
</TransformWrapper>
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
<Meta
|
|
25
|
-
title="Examples/Small Image"
|
|
26
|
-
component={TransformWrapper}
|
|
27
|
-
argTypes={argsTypes}
|
|
28
|
-
/>
|
|
29
|
-
|
|
30
|
-
# Small Image
|
|
31
|
-
|
|
32
|
-
<br />
|
|
33
|
-
|
|
34
|
-
### Preview:
|
|
35
|
-
|
|
36
|
-
<Canvas>
|
|
37
|
-
<Story name="Small Image">{(args) => <Template {...args} />}</Story>
|
|
38
|
-
</Canvas>
|
|
39
|
-
|
|
40
|
-
## Component API
|
|
41
|
-
|
|
42
|
-
<ArgsTable story="Small Image" />
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, ArgsTable, Canvas } from "@storybook/addon-docs/blocks";
|
|
2
|
-
import { action } from "@storybook/addon-actions";
|
|
3
|
-
|
|
4
|
-
import { TransformWrapper } from "../../../components/transform-wrapper";
|
|
5
|
-
import { TransformComponent } from "../../../components/transform-component";
|
|
6
|
-
import { argsTypes } from "../../types/args.types.ts";
|
|
7
|
-
import { normalizeArgs, Controls } from "../../utils";
|
|
8
|
-
|
|
9
|
-
import exampleImg from "../../assets/medium-image.jpg";
|
|
10
|
-
|
|
11
|
-
export const Template = (args) => (
|
|
12
|
-
<TransformWrapper
|
|
13
|
-
{...normalizeArgs(args)}
|
|
14
|
-
initialScale={0.4}
|
|
15
|
-
minScale={0.2}
|
|
16
|
-
centerOnInit={true}
|
|
17
|
-
>
|
|
18
|
-
{(utils) => (
|
|
19
|
-
<div>
|
|
20
|
-
<Controls {...utils} />
|
|
21
|
-
<TransformComponent>
|
|
22
|
-
<img src={exampleImg} alt="" />
|
|
23
|
-
</TransformComponent>
|
|
24
|
-
</div>
|
|
25
|
-
)}
|
|
26
|
-
</TransformWrapper>
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
<Meta
|
|
30
|
-
title="Examples/Zoomed Out"
|
|
31
|
-
component={TransformWrapper}
|
|
32
|
-
argTypes={argsTypes}
|
|
33
|
-
/>
|
|
34
|
-
|
|
35
|
-
# Zoomed Out
|
|
36
|
-
|
|
37
|
-
<br />
|
|
38
|
-
|
|
39
|
-
### Preview:
|
|
40
|
-
|
|
41
|
-
<Canvas>
|
|
42
|
-
<Story name="Zoomed Out">{(args) => <Template {...args} />}</Story>
|
|
43
|
-
</Canvas>
|
|
44
|
-
|
|
45
|
-
## Component API
|
|
46
|
-
|
|
47
|
-
<ArgsTable story="Zoomed Out" />
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { TransformWrapper } from "../../../components/transform-wrapper";
|
|
4
|
-
import { TransformComponent } from "../../../components/transform-component";
|
|
5
|
-
import { normalizeArgs } from "../../utils";
|
|
6
|
-
import { KeepScale } from "components/keep-scale";
|
|
7
|
-
import exampleImg from "../../assets/map.jpg";
|
|
8
|
-
import { ReactComponent as Pin } from "../../assets/pin.svg";
|
|
9
|
-
|
|
10
|
-
export const Example: React.FC<any> = (args: any) => {
|
|
11
|
-
return (
|
|
12
|
-
<TransformWrapper {...normalizeArgs(args)} maxScale={100}>
|
|
13
|
-
<TransformComponent
|
|
14
|
-
wrapperStyle={{
|
|
15
|
-
width: "700px",
|
|
16
|
-
height: "500px",
|
|
17
|
-
maxWidth: "100%",
|
|
18
|
-
maxHeight: "calc(100vh - 50px)",
|
|
19
|
-
}}
|
|
20
|
-
>
|
|
21
|
-
<div
|
|
22
|
-
style={{
|
|
23
|
-
position: "relative",
|
|
24
|
-
background: "#999",
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
27
|
-
<h2>Pins will keep the initial scale with KeepScale component</h2>
|
|
28
|
-
|
|
29
|
-
<img
|
|
30
|
-
style={{ width: "600px", height: "300px" }}
|
|
31
|
-
src={exampleImg}
|
|
32
|
-
alt=""
|
|
33
|
-
/>
|
|
34
|
-
<div
|
|
35
|
-
style={{
|
|
36
|
-
position: "absolute",
|
|
37
|
-
top: "50%",
|
|
38
|
-
left: "50%",
|
|
39
|
-
transform: "translate(-50%, -50%)",
|
|
40
|
-
zIndex: 2,
|
|
41
|
-
marginLeft: "-200px",
|
|
42
|
-
}}
|
|
43
|
-
>
|
|
44
|
-
<KeepScale>
|
|
45
|
-
<Pin fill="red" style={{ width: "20px", height: "20px" }} />
|
|
46
|
-
</KeepScale>
|
|
47
|
-
</div>
|
|
48
|
-
<div
|
|
49
|
-
style={{
|
|
50
|
-
position: "absolute",
|
|
51
|
-
top: "50%",
|
|
52
|
-
left: "50%",
|
|
53
|
-
transform: "translate(-50%, -50%)",
|
|
54
|
-
zIndex: 2,
|
|
55
|
-
marginLeft: "200px",
|
|
56
|
-
}}
|
|
57
|
-
>
|
|
58
|
-
<KeepScale>
|
|
59
|
-
<Pin fill="red" style={{ width: "20px", height: "20px" }} />
|
|
60
|
-
</KeepScale>
|
|
61
|
-
</div>
|
|
62
|
-
<div
|
|
63
|
-
style={{
|
|
64
|
-
position: "absolute",
|
|
65
|
-
top: "50%",
|
|
66
|
-
left: "50%",
|
|
67
|
-
transform: "translate(-50%, -50%)",
|
|
68
|
-
zIndex: 2,
|
|
69
|
-
marginBottom: "150px",
|
|
70
|
-
}}
|
|
71
|
-
>
|
|
72
|
-
<KeepScale>
|
|
73
|
-
<Pin fill="red" style={{ width: "20px", height: "20px" }} />
|
|
74
|
-
</KeepScale>
|
|
75
|
-
</div>
|
|
76
|
-
<div
|
|
77
|
-
style={{
|
|
78
|
-
position: "absolute",
|
|
79
|
-
top: "50%",
|
|
80
|
-
left: "50%",
|
|
81
|
-
transform: "translate(-50%, -50%)",
|
|
82
|
-
zIndex: 2,
|
|
83
|
-
marginTop: "100px",
|
|
84
|
-
}}
|
|
85
|
-
>
|
|
86
|
-
<KeepScale>
|
|
87
|
-
<Pin fill="red" style={{ width: "20px", height: "20px" }} />
|
|
88
|
-
</KeepScale>
|
|
89
|
-
</div>
|
|
90
|
-
</div>
|
|
91
|
-
</TransformComponent>
|
|
92
|
-
</TransformWrapper>
|
|
93
|
-
);
|
|
94
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, ArgsTable, Canvas } from "@storybook/addon-docs/blocks";
|
|
2
|
-
import { action } from "@storybook/addon-actions";
|
|
3
|
-
|
|
4
|
-
import { TransformWrapper } from "../../../components/transform-wrapper";
|
|
5
|
-
import { argsTypes } from "../../types/args.types";
|
|
6
|
-
import { Example } from "./example";
|
|
7
|
-
|
|
8
|
-
export const Template = (args) => <Example {...args} />;
|
|
9
|
-
|
|
10
|
-
<Meta
|
|
11
|
-
title="Examples/Keep scale"
|
|
12
|
-
component={TransformWrapper}
|
|
13
|
-
argTypes={{
|
|
14
|
-
...argsTypes,
|
|
15
|
-
"wheel.excluded": {
|
|
16
|
-
...argsTypes["wheel.excluded"],
|
|
17
|
-
defaultValue: ["wheelDisabled"],
|
|
18
|
-
},
|
|
19
|
-
"panning.excluded": {
|
|
20
|
-
...argsTypes["panning.excluded"],
|
|
21
|
-
defaultValue: ["panningDisabled"],
|
|
22
|
-
},
|
|
23
|
-
"pinch.excluded": {
|
|
24
|
-
...argsTypes["pinch.excluded"],
|
|
25
|
-
defaultValue: ["pinchDisabled"],
|
|
26
|
-
},
|
|
27
|
-
centerOnInit: {
|
|
28
|
-
defaultValue: true,
|
|
29
|
-
},
|
|
30
|
-
}}
|
|
31
|
-
/>
|
|
32
|
-
|
|
33
|
-
# Keep scale
|
|
34
|
-
|
|
35
|
-
<br />
|
|
36
|
-
|
|
37
|
-
### Preview:
|
|
38
|
-
|
|
39
|
-
<Canvas>
|
|
40
|
-
<Story name="Keep scale">{(args) => <Template {...args} />}</Story>
|
|
41
|
-
</Canvas>
|
|
42
|
-
|
|
43
|
-
## Component API
|
|
44
|
-
|
|
45
|
-
<ArgsTable story="Keep scale" />
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from "react";
|
|
2
|
-
|
|
3
|
-
import { TransformWrapper } from "../../../components/transform-wrapper";
|
|
4
|
-
import { TransformComponent } from "../../../components/transform-component";
|
|
5
|
-
import { normalizeArgs } from "../../utils";
|
|
6
|
-
import exampleImg from "../../assets/small-image.jpg";
|
|
7
|
-
|
|
8
|
-
import styles from "../../utils/styles.module.css";
|
|
9
|
-
|
|
10
|
-
export const Example: React.FC<any> = (args: any) => {
|
|
11
|
-
const ref = useRef<any>(null);
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<TransformWrapper {...normalizeArgs(args)} ref={ref}>
|
|
15
|
-
<TransformComponent>
|
|
16
|
-
<div className={styles.grid}>
|
|
17
|
-
{Array.from(Array(1000).keys()).map((key) => (
|
|
18
|
-
<img key={key} src={exampleImg} alt="" />
|
|
19
|
-
))}
|
|
20
|
-
</div>
|
|
21
|
-
</TransformComponent>
|
|
22
|
-
</TransformWrapper>
|
|
23
|
-
);
|
|
24
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, ArgsTable, Canvas } from "@storybook/addon-docs/blocks";
|
|
2
|
-
import { action } from "@storybook/addon-actions";
|
|
3
|
-
|
|
4
|
-
import { TransformWrapper } from "../../../components/transform-wrapper";
|
|
5
|
-
import { argsTypes } from "../../types/args.types";
|
|
6
|
-
import { Example } from "./example";
|
|
7
|
-
|
|
8
|
-
export const Template = (args) => <Example {...args} />;
|
|
9
|
-
|
|
10
|
-
<Meta
|
|
11
|
-
title="Examples/Stress test"
|
|
12
|
-
component={TransformWrapper}
|
|
13
|
-
argTypes={argsTypes}
|
|
14
|
-
/>
|
|
15
|
-
|
|
16
|
-
# Stress test
|
|
17
|
-
|
|
18
|
-
<br />
|
|
19
|
-
|
|
20
|
-
### Preview:
|
|
21
|
-
|
|
22
|
-
<Canvas>
|
|
23
|
-
<Story name="Stress test">{(args) => <Template {...args} />}</Story>
|
|
24
|
-
</Canvas>
|
|
25
|
-
|
|
26
|
-
## Component API
|
|
27
|
-
|
|
28
|
-
<ArgsTable story="Stress test" />
|