react-zoom-pan-pinch 3.2.0 → 3.4.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/index.cjs.js +54 -33
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.esm.js +54 -33
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -1
- package/.eslintignore +0 -6
- package/.github/CODEOWNERS +0 -36
- package/.github/FUNDING.yml +0 -13
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/workflows/docs.yml +0 -34
- package/.github/workflows/release.yml +0 -46
- package/.github/workflows/tests.yml +0 -42
- package/.prettierrc +0 -10
- package/.releaserc.json +0 -63
- package/.storybook/main.js +0 -23
- package/.storybook/preview-head.html +0 -5
- package/.storybook/preview.js +0 -11
- package/.storybook/theme-overrides.css +0 -49
- package/CHANGELOG.md +0 -26
- package/Code_of_Conduct.md +0 -61
- package/Contributing.md +0 -236
- package/__tests__/features/props.spec.tsx +0 -11
- package/__tests__/features/rendering.spec.tsx +0 -36
- package/__tests__/shared/render.shared.tsx +0 -41
- package/__tests__/utils/controls.utils.tsx +0 -25
- package/__tests__/utils/example.tsx +0 -81
- package/commitlint.config.js +0 -1
- package/dist/__tests__/features/props.spec.d.ts +0 -1
- package/dist/__tests__/features/rendering.spec.d.ts +0 -1
- package/dist/__tests__/shared/render.shared.d.ts +0 -11
- package/dist/__tests__/utils/controls.utils.d.ts +0 -3
- package/dist/__tests__/utils/example.d.ts +0 -6
- package/dist/src/components/index.d.ts +0 -4
- package/dist/src/components/keep-scale/keep-scale.d.ts +0 -2
- package/dist/src/components/mini-map/mini-map.d.ts +0 -8
- package/dist/src/components/mini-map/use-resize.hook.d.ts +0 -8
- package/dist/src/components/transform-component/transform-component.d.ts +0 -12
- package/dist/src/components/transform-wrapper/transform-wrapper.d.ts +0 -5
- package/dist/src/constants/state.constants.d.ts +0 -3
- package/dist/src/core/animations/animations.constants.d.ts +0 -16
- package/dist/src/core/animations/animations.utils.d.ts +0 -4
- package/dist/src/core/bounds/bounds.types.d.ts +0 -8
- package/dist/src/core/bounds/bounds.utils.d.ts +0 -17
- package/dist/src/core/double-click/double-click.logic.d.ts +0 -5
- package/dist/src/core/handlers/handlers.logic.d.ts +0 -8
- package/dist/src/core/handlers/handlers.utils.d.ts +0 -14
- package/dist/src/core/instance.core.d.ts +0 -77
- package/dist/src/core/pan/panning.logic.d.ts +0 -5
- package/dist/src/core/pan/panning.utils.d.ts +0 -10
- package/dist/src/core/pan/velocity.logic.d.ts +0 -5
- package/dist/src/core/pan/velocity.utils.d.ts +0 -5
- package/dist/src/core/pinch/pinch.logic.d.ts +0 -4
- package/dist/src/core/pinch/pinch.utils.d.ts +0 -6
- package/dist/src/core/wheel/wheel.logic.d.ts +0 -4
- package/dist/src/core/wheel/wheel.utils.d.ts +0 -7
- package/dist/src/core/zoom/zoom.logic.d.ts +0 -3
- package/dist/src/core/zoom/zoom.utils.d.ts +0 -3
- package/dist/src/hooks/index.d.ts +0 -4
- package/dist/src/hooks/use-controls.d.ts +0 -2
- package/dist/src/hooks/use-transform-context.d.ts +0 -1
- package/dist/src/hooks/use-transform-effect.d.ts +0 -2
- package/dist/src/hooks/use-transform-init.d.ts +0 -2
- package/dist/src/index.d.ts +0 -5
- package/dist/src/models/calculations.model.d.ts +0 -25
- package/dist/src/models/context.model.d.ts +0 -124
- package/dist/src/models/helpers.model.d.ts +0 -5
- package/dist/src/models/index.d.ts +0 -3
- package/dist/src/stories/docs/handlers.d.ts +0 -12
- package/dist/src/stories/docs/props.d.ts +0 -14
- package/dist/src/stories/examples/content-rerendering/example.d.ts +0 -2
- package/dist/src/stories/examples/image-responsive/example.d.ts +0 -2
- package/dist/src/stories/examples/keep-scale/example.d.ts +0 -2
- package/dist/src/stories/examples/mini-map/example.d.ts +0 -1
- package/dist/src/stories/examples/stress/example.d.ts +0 -2
- package/dist/src/stories/examples/svg-zoom-to-element/example.d.ts +0 -2
- package/dist/src/stories/examples/zoom-to-element/example.d.ts +0 -2
- package/dist/src/stories/types/args.types.d.ts +0 -280
- package/dist/src/stories/utils/args.utils.d.ts +0 -3
- package/dist/src/stories/utils/code.utils.d.ts +0 -6
- package/dist/src/stories/utils/controls.utils.d.ts +0 -3
- package/dist/src/stories/utils/index.d.ts +0 -3
- package/dist/src/utils/calculations.utils.d.ts +0 -11
- package/dist/src/utils/callback.utils.d.ts +0 -2
- package/dist/src/utils/context.utils.d.ts +0 -4
- package/dist/src/utils/event.utils.d.ts +0 -1
- package/dist/src/utils/helpers.utils.d.ts +0 -2
- package/dist/src/utils/index.d.ts +0 -8
- package/dist/src/utils/ref.utils.d.ts +0 -2
- package/dist/src/utils/state.utils.d.ts +0 -3
- package/dist/src/utils/styles.utils.d.ts +0 -4
- package/jest.config.ts +0 -45
- package/rollup.config.js +0 -51
- package/src/.eslintrc.json +0 -90
- package/src/components/index.ts +0 -4
- package/src/components/keep-scale/keep-scale.tsx +0 -28
- package/src/components/mini-map/mini-map.tsx +0 -188
- package/src/components/mini-map/use-resize.hook.ts +0 -69
- package/src/components/transform-component/transform-component.module.css +0 -30
- package/src/components/transform-component/transform-component.tsx +0 -58
- package/src/components/transform-wrapper/transform-wrapper.tsx +0 -42
- package/src/constants/state.constants.ts +0 -74
- package/src/core/animations/animations.constants.ts +0 -78
- package/src/core/animations/animations.utils.ts +0 -114
- package/src/core/bounds/bounds.types.ts +0 -8
- package/src/core/bounds/bounds.utils.ts +0 -198
- package/src/core/double-click/double-click.logic.ts +0 -116
- package/src/core/handlers/handlers.logic.ts +0 -115
- package/src/core/handlers/handlers.utils.ts +0 -195
- package/src/core/instance.core.ts +0 -499
- package/src/core/pan/panning.logic.ts +0 -100
- package/src/core/pan/panning.utils.ts +0 -196
- package/src/core/pan/velocity.logic.ts +0 -149
- package/src/core/pan/velocity.utils.ts +0 -79
- package/src/core/pinch/pinch.logic.ts +0 -81
- package/src/core/pinch/pinch.utils.ts +0 -88
- package/src/core/wheel/wheel.logic.ts +0 -121
- package/src/core/wheel/wheel.utils.ts +0 -122
- package/src/core/zoom/zoom.logic.ts +0 -69
- package/src/core/zoom/zoom.utils.ts +0 -58
- package/src/hooks/index.ts +0 -4
- package/src/hooks/use-controls.tsx +0 -9
- package/src/hooks/use-transform-context.tsx +0 -13
- package/src/hooks/use-transform-effect.tsx +0 -22
- package/src/hooks/use-transform-init.tsx +0 -27
- package/src/index.ts +0 -6
- package/src/models/calculations.model.ts +0 -26
- package/src/models/context.model.ts +0 -196
- package/src/models/helpers.model.ts +0 -15
- package/src/models/index.ts +0 -3
- package/src/react-app-env.d.ts +0 -1
- 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 -174
- 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 -508
- package/src/stories/examples/content/content.stories.mdx +0 -121
- package/src/stories/examples/content-rerendering/content-updating.stories.mdx +0 -45
- package/src/stories/examples/content-rerendering/example.tsx +0 -73
- package/src/stories/examples/controls/controls.stories.mdx +0 -71
- package/src/stories/examples/image-big/image-big.stories.mdx +0 -43
- package/src/stories/examples/image-medium/image-medium.stories.mdx +0 -41
- package/src/stories/examples/image-responsive/example.tsx +0 -103
- package/src/stories/examples/image-responsive/image-responsive.stories.mdx +0 -32
- package/src/stories/examples/image-small/image-small.stories.mdx +0 -41
- package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +0 -46
- package/src/stories/examples/keep-scale/example.tsx +0 -92
- package/src/stories/examples/keep-scale/keep-scale.stories.mdx +0 -45
- package/src/stories/examples/mini-map/example.tsx +0 -54
- package/src/stories/examples/mini-map/mini-map.stories.mdx +0 -33
- package/src/stories/examples/stress/example.tsx +0 -23
- 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 -94
- package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +0 -28
- package/src/stories/hooks/use-controls.stories.mdx +0 -24
- package/src/stories/hooks/use-transform-context.stories.mdx +0 -15
- package/src/stories/hooks/use-transform-effect.stories.mdx +0 -29
- package/src/stories/hooks/use-transform-init.stories.mdx +0 -25
- package/src/stories/types/args.types.ts +0 -211
- package/src/stories/utils/args.utils.ts +0 -34
- package/src/stories/utils/code.utils.tsx +0 -24
- 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/src/styles.css +0 -8
- package/src/typings.d.ts +0 -10
- package/src/utils/calculations.utils.ts +0 -16
- package/src/utils/callback.utils.ts +0 -11
- package/src/utils/context.utils.ts +0 -48
- package/src/utils/event.utils.ts +0 -22
- package/src/utils/helpers.utils.ts +0 -27
- package/src/utils/index.ts +0 -8
- package/src/utils/ref.utils.ts +0 -16
- package/src/utils/state.utils.ts +0 -40
- package/src/utils/styles.utils.ts +0 -44
- package/tsconfig.json +0 -33
package/src/models/index.ts
DELETED
package/src/react-app-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="react-scripts" />
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m12 0c-4.962 0-9 4.066-9 9.065 0 7.103 8.154 14.437 8.501 14.745.143.127.321.19.499.19s.356-.063.499-.189c.347-.309 8.501-7.643 8.501-14.746 0-4.999-4.038-9.065-9-9.065zm0 14c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z"/></svg>
|
|
Binary file
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<svg version="1.1"
|
|
2
|
-
baseProfile="full"
|
|
3
|
-
width="300" height="200"
|
|
4
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
-
id="example-svg"
|
|
6
|
-
>
|
|
7
|
-
|
|
8
|
-
<rect width="100%" height="100%" fill="red" />
|
|
9
|
-
|
|
10
|
-
<circle cx="150" cy="100" r="80" fill="green" />
|
|
11
|
-
|
|
12
|
-
<text x="150" y="125" font-size="30" text-anchor="middle" fill="white" id="text-svg">Example</text>
|
|
13
|
-
|
|
14
|
-
</svg>
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
-
|
|
3
|
-
<Meta title="Docs/Introduction" />
|
|
4
|
-
|
|
5
|
-
# 🖼 React Zoom Pan Pinch
|
|
6
|
-
|
|
7
|
-
<p>
|
|
8
|
-
<a href="https://bettertyped.com/">
|
|
9
|
-
<img src="https://custom-icon-badges.demolab.com/static/v1?label=&message=BetterTyped&color=333&logo=BT" />
|
|
10
|
-
</a>
|
|
11
|
-
<a href="https://www.npmjs.com/package/react-zoom-pan-pinch">
|
|
12
|
-
<img src="https://custom-icon-badges.demolab.com/npm/v/react-zoom-pan-pinch.svg?logo=npm&color=e22121" />
|
|
13
|
-
</a>
|
|
14
|
-
<a href="https://github.com/prc5/react-zoom-pan-pinch">
|
|
15
|
-
<img src="https://custom-icon-badges.demolab.com/github/stars/prc5/react-zoom-pan-pinch?logo=star" />
|
|
16
|
-
</a>
|
|
17
|
-
<a href="https://github.com/prc5/react-zoom-pan-pinch/blob/main/License.md">
|
|
18
|
-
<img src="https://custom-icon-badges.demolab.com/github/license/prc5/react-zoom-pan-pinch?logo=law&color=yellow" />
|
|
19
|
-
</a>
|
|
20
|
-
<a href="https://github.com/semantic-release/semantic-release">
|
|
21
|
-
<img src="https://custom-icon-badges.demolab.com/badge/semver-commitzen-e10079?logo=semantic-release&color=e76f51" />
|
|
22
|
-
</a>
|
|
23
|
-
<a href="https://www.npmjs.com/package/react-zoom-pan-pinch">
|
|
24
|
-
<img src="https://custom-icon-badges.demolab.com/npm/dm/react-zoom-pan-pinch?logoColor=fff&logo=trending-up" />
|
|
25
|
-
</a>
|
|
26
|
-
<a href="https://www.npmjs.com/package/react-zoom-pan-pinch">
|
|
27
|
-
<img src="https://custom-icon-badges.demolab.com/bundlephobia/minzip/react-zoom-pan-pinch?color=E10098&logo=package" />
|
|
28
|
-
</a>
|
|
29
|
-
<a href="https://github.com/prc5/react-zoom-pan-pinch">
|
|
30
|
-
<img src="https://custom-icon-badges.demolab.com/badge/typescript-%23007ACC.svg?logo=typescript&logoColor=white" />
|
|
31
|
-
</a>
|
|
32
|
-
<a href="https://hits.sh/github.com/prc5/react-zoom-pan-pinch/">
|
|
33
|
-
<img src="https://hits.sh/github.com/prc5/react-zoom-pan-pinch.svg?color=64BC4B&logo=bookmeter" />
|
|
34
|
-
</a>
|
|
35
|
-
<a href="https://twitter.com/maciej_pyrc">
|
|
36
|
-
<img
|
|
37
|
-
alt="Twitter Follow"
|
|
38
|
-
src="https://img.shields.io/twitter/follow/maciej_pyrc?label=Follow%20&style=social"
|
|
39
|
-
/>
|
|
40
|
-
</a>
|
|
41
|
-
</p>
|
|
42
|
-
|
|
43
|
-
> Super fast and light react npm package for zooming, panning and pinching html
|
|
44
|
-
> elements in easy way
|
|
45
|
-
|
|
46
|
-
- [Demo](https://prc5.github.io/react-zoom-pan-pinch/?path=/story/examples-big-image--big-image)
|
|
47
|
-
- [Docs](https://prc5.github.io/react-zoom-pan-pinch/?path=/story/docs-props--page)
|
|
48
|
-
|
|
49
|
-
## Key Features
|
|
50
|
-
|
|
51
|
-
- 🚀 Fast and easy to use
|
|
52
|
-
- 🏭 Light, without external dependencies
|
|
53
|
-
- 💎 Mobile gestures, touchpad gestures and desktop mouse events support
|
|
54
|
-
- 🎁 Powerful context usage, which gives you a lot of freedom
|
|
55
|
-
- 🔧 Highly customizable
|
|
56
|
-
- 👑 Animations and Utils to create own tools
|
|
57
|
-
- 🔮 Advanced hooks and components
|
|
58
|
-
|
|
59
|
-
## Help me keep working on this project ❤️
|
|
60
|
-
|
|
61
|
-
- [Become a Sponsor on GitHub](https://github.com/sponsors/prc5)
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Installation
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
npm install --save react-zoom-pan-pinch
|
|
69
|
-
or
|
|
70
|
-
yarn add react-zoom-pan-pinch
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Examples
|
|
74
|
-
|
|
75
|
-
```jsx
|
|
76
|
-
import React, { Component } from "react";
|
|
77
|
-
|
|
78
|
-
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
|
|
79
|
-
|
|
80
|
-
const Example = () => {
|
|
81
|
-
return (
|
|
82
|
-
<TransformWrapper>
|
|
83
|
-
<TransformComponent>
|
|
84
|
-
<img src="image.jpg" alt="test" />
|
|
85
|
-
</TransformComponent>
|
|
86
|
-
</TransformWrapper>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
or
|
|
92
|
-
|
|
93
|
-
```jsx
|
|
94
|
-
import React, { Component } from "react";
|
|
95
|
-
|
|
96
|
-
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
|
|
97
|
-
|
|
98
|
-
const Example = () => {
|
|
99
|
-
return (
|
|
100
|
-
<TransformWrapper
|
|
101
|
-
initialScale={1}
|
|
102
|
-
initialPositionX={200}
|
|
103
|
-
initialPositionY={100}
|
|
104
|
-
>
|
|
105
|
-
{({ zoomIn, zoomOut, resetTransform, ...rest }) => (
|
|
106
|
-
<React.Fragment>
|
|
107
|
-
<div className="tools">
|
|
108
|
-
<button onClick={() => zoomIn()}>+</button>
|
|
109
|
-
<button onClick={() => zoomOut()}>-</button>
|
|
110
|
-
<button onClick={() => resetTransform()}>x</button>
|
|
111
|
-
</div>
|
|
112
|
-
<TransformComponent>
|
|
113
|
-
<img src="image.jpg" alt="test" />
|
|
114
|
-
<div>Example text</div>
|
|
115
|
-
</TransformComponent>
|
|
116
|
-
</React.Fragment>
|
|
117
|
-
)}
|
|
118
|
-
</TransformWrapper>
|
|
119
|
-
);
|
|
120
|
-
};
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
or
|
|
124
|
-
|
|
125
|
-
```tsx
|
|
126
|
-
import React, { useRef } from "react";
|
|
127
|
-
import {
|
|
128
|
-
TransformWrapper,
|
|
129
|
-
TransformComponent,
|
|
130
|
-
ReactZoomPanPinchRef,
|
|
131
|
-
} from "react-zoom-pan-pinch";
|
|
132
|
-
|
|
133
|
-
const Controls = ({ zoomIn, zoomOut, resetTransform }) => (
|
|
134
|
-
<>
|
|
135
|
-
<button onClick={() => zoomIn()}>+</button>
|
|
136
|
-
<button onClick={() => zoomOut()}>-</button>
|
|
137
|
-
<button onClick={() => resetTransform()}>x</button>
|
|
138
|
-
</>
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
const Component = () => {
|
|
142
|
-
const transformComponentRef = useRef<ReactZoomPanPinchRef | null>(null);
|
|
143
|
-
|
|
144
|
-
const zoomToImage = () => {
|
|
145
|
-
if (transformComponentRef.current) {
|
|
146
|
-
const { zoomToElement } = transformComponentRef.current;
|
|
147
|
-
zoomToElement("imgExample");
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
<TransformWrapper
|
|
153
|
-
initialScale={1}
|
|
154
|
-
initialPositionX={200}
|
|
155
|
-
initialPositionY={100}
|
|
156
|
-
ref={transformComponentRef}
|
|
157
|
-
>
|
|
158
|
-
{(utils) => (
|
|
159
|
-
<React.Fragment>
|
|
160
|
-
<Controls {...utils} />
|
|
161
|
-
<TransformComponent>
|
|
162
|
-
<img src="image.jpg" alt="test" id="imgExample" />
|
|
163
|
-
<div onClick={zoomToImage}>Example text</div>
|
|
164
|
-
</TransformComponent>
|
|
165
|
-
</React.Fragment>
|
|
166
|
-
)}
|
|
167
|
-
</TransformWrapper>
|
|
168
|
-
);
|
|
169
|
-
};
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
## License
|
|
173
|
-
|
|
174
|
-
MIT © [prc5](https://github.com/prc5)
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
-
|
|
3
|
-
import { getHandlersTable } from "./handlers.tsx";
|
|
4
|
-
import { Code } from "../utils";
|
|
5
|
-
|
|
6
|
-
<Meta title="Docs/Handlers" />
|
|
7
|
-
|
|
8
|
-
# Handlers
|
|
9
|
-
|
|
10
|
-
List of additionaly added handlers - you can acces them via ref or render props
|
|
11
|
-
|
|
12
|
-
<table className="handlers-table">
|
|
13
|
-
<thead>
|
|
14
|
-
<tr>
|
|
15
|
-
<th>
|
|
16
|
-
Name
|
|
17
|
-
</th>
|
|
18
|
-
<th>
|
|
19
|
-
Type
|
|
20
|
-
</th>
|
|
21
|
-
<th>
|
|
22
|
-
Default
|
|
23
|
-
</th>
|
|
24
|
-
<th>
|
|
25
|
-
Description
|
|
26
|
-
</th>
|
|
27
|
-
</tr>
|
|
28
|
-
</thead>
|
|
29
|
-
<tbody>
|
|
30
|
-
{getHandlersTable().map(row => (
|
|
31
|
-
<tr className={row.isObjectRow ? "is-object-row" : ""}>
|
|
32
|
-
<td>
|
|
33
|
-
{row.name}
|
|
34
|
-
</td>
|
|
35
|
-
<td>
|
|
36
|
-
{row.type.map(type => (<Code code={type} />))}
|
|
37
|
-
</td>
|
|
38
|
-
<td>
|
|
39
|
-
{row.parameters.map(param => (<Code code={param} />))}
|
|
40
|
-
</td>
|
|
41
|
-
<td>
|
|
42
|
-
{row.description}
|
|
43
|
-
</td>
|
|
44
|
-
</tr>
|
|
45
|
-
))}
|
|
46
|
-
</tbody>
|
|
47
|
-
|
|
48
|
-
</table>
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { ReactZoomPanPinchHandlers } from "../../models/context.model";
|
|
4
|
-
|
|
5
|
-
export type ControlsFnOptionsType = {
|
|
6
|
-
name: React.ReactNode;
|
|
7
|
-
type: string[];
|
|
8
|
-
parameters: string[];
|
|
9
|
-
description: string;
|
|
10
|
-
isObjectRow?: boolean;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type ComponentProps = Record<
|
|
14
|
-
keyof ReactZoomPanPinchHandlers,
|
|
15
|
-
| Omit<ControlsFnOptionsType, "name" | "isObjectRow">
|
|
16
|
-
| Record<string, Omit<ControlsFnOptionsType, "name" | "isObjectRow">>
|
|
17
|
-
>;
|
|
18
|
-
|
|
19
|
-
export const handlersTable: ComponentProps = {
|
|
20
|
-
zoomIn: {
|
|
21
|
-
type: ["function(step, animationTime, animationName)"],
|
|
22
|
-
parameters: [
|
|
23
|
-
"step: number = 0.5",
|
|
24
|
-
"animationTime: number = 300",
|
|
25
|
-
"animationName: string = easeOut",
|
|
26
|
-
],
|
|
27
|
-
description: "Function used for zoom in button",
|
|
28
|
-
},
|
|
29
|
-
zoomOut: {
|
|
30
|
-
type: ["function(step, animationTime, animationName)"],
|
|
31
|
-
parameters: [
|
|
32
|
-
"step: number = 0.5",
|
|
33
|
-
"animationTime: number = 300",
|
|
34
|
-
"animationName: string = easeOut",
|
|
35
|
-
],
|
|
36
|
-
description: "Function used for zoom out button",
|
|
37
|
-
},
|
|
38
|
-
setTransform: {
|
|
39
|
-
type: ["function(x, y, scale, animationTime, animationName)"],
|
|
40
|
-
parameters: [
|
|
41
|
-
"x: number",
|
|
42
|
-
"y: number",
|
|
43
|
-
"scale: number",
|
|
44
|
-
"animationTime: number = 300",
|
|
45
|
-
"animationName: string = easeOut",
|
|
46
|
-
],
|
|
47
|
-
description: "Function used for custom transformation animation",
|
|
48
|
-
},
|
|
49
|
-
resetTransform: {
|
|
50
|
-
type: ["function(animationTime, animationName)"],
|
|
51
|
-
parameters: [
|
|
52
|
-
"animationTime: number = 300",
|
|
53
|
-
"animationName: string = easeOut",
|
|
54
|
-
],
|
|
55
|
-
description: "Function used for reset button",
|
|
56
|
-
},
|
|
57
|
-
centerView: {
|
|
58
|
-
type: ["function(scale, animationTime, animationName)"],
|
|
59
|
-
parameters: [
|
|
60
|
-
"scale: number = undefined",
|
|
61
|
-
"animationTime: number = 300",
|
|
62
|
-
"animationName: string = easeOut",
|
|
63
|
-
],
|
|
64
|
-
description: "Function used for centering the content component",
|
|
65
|
-
},
|
|
66
|
-
zoomToElement: {
|
|
67
|
-
type: ["function(node, customZoom, animationTime, animationName)"],
|
|
68
|
-
parameters: [
|
|
69
|
-
"node: HTMLElement | string",
|
|
70
|
-
"customScale: number = undefined",
|
|
71
|
-
"animationTime: number = 300",
|
|
72
|
-
"animationName: string = easeOut",
|
|
73
|
-
],
|
|
74
|
-
description:
|
|
75
|
-
"This function make a transition for certain node provided to the function(as node element or it's id string). It allows only to zoom elements with offsetWidth and offsetHeight properties - since SVG's doesn't have those, it is impossible to perform it on such elements.",
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const getHandlersTable = (): ControlsFnOptionsType[] => {
|
|
80
|
-
return Object.keys(handlersTable).reduce<ControlsFnOptionsType[]>(
|
|
81
|
-
(acc, key) => {
|
|
82
|
-
if (Array.isArray(handlersTable[key]?.type)) {
|
|
83
|
-
acc.push({
|
|
84
|
-
...handlersTable[key],
|
|
85
|
-
name: key,
|
|
86
|
-
});
|
|
87
|
-
} else {
|
|
88
|
-
Object.keys(handlersTable[key]).forEach((prop) => {
|
|
89
|
-
acc.push({
|
|
90
|
-
...handlersTable[key][prop],
|
|
91
|
-
isObjectRow: key === prop,
|
|
92
|
-
name:
|
|
93
|
-
key === prop ? (
|
|
94
|
-
<b>{prop}</b>
|
|
95
|
-
) : (
|
|
96
|
-
<>
|
|
97
|
-
{key}.<b>{prop}</b>
|
|
98
|
-
</>
|
|
99
|
-
),
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
return acc;
|
|
104
|
-
},
|
|
105
|
-
[],
|
|
106
|
-
);
|
|
107
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
-
|
|
3
|
-
import { componentProps, wrapperProps } from "./props.tsx";
|
|
4
|
-
import { Code } from "../utils";
|
|
5
|
-
|
|
6
|
-
<Meta title="Docs/Props" />
|
|
7
|
-
|
|
8
|
-
# TransformComponent Props
|
|
9
|
-
|
|
10
|
-
List of props
|
|
11
|
-
|
|
12
|
-
<table className="props-table">
|
|
13
|
-
<thead>
|
|
14
|
-
<tr>
|
|
15
|
-
<th>
|
|
16
|
-
Name
|
|
17
|
-
</th>
|
|
18
|
-
<th>
|
|
19
|
-
Type
|
|
20
|
-
</th>
|
|
21
|
-
<th>
|
|
22
|
-
Default
|
|
23
|
-
</th>
|
|
24
|
-
<th>
|
|
25
|
-
Description
|
|
26
|
-
</th>
|
|
27
|
-
</tr>
|
|
28
|
-
</thead>
|
|
29
|
-
<tbody>
|
|
30
|
-
{componentProps.map(row => (
|
|
31
|
-
<tr className={row.isObjectRow ? "is-object-row" : ""}>
|
|
32
|
-
<td>
|
|
33
|
-
{row.name}
|
|
34
|
-
</td>
|
|
35
|
-
<td>
|
|
36
|
-
{row.type.map(type => (<Code code={type} />))}
|
|
37
|
-
</td>
|
|
38
|
-
<td>
|
|
39
|
-
<Code code={row.defaultValue} />
|
|
40
|
-
</td>
|
|
41
|
-
<td>
|
|
42
|
-
{row.description}
|
|
43
|
-
</td>
|
|
44
|
-
</tr>
|
|
45
|
-
))}
|
|
46
|
-
</tbody>
|
|
47
|
-
|
|
48
|
-
</table>
|
|
49
|
-
|
|
50
|
-
<br />
|
|
51
|
-
|
|
52
|
-
# TransformWrapper Props
|
|
53
|
-
|
|
54
|
-
List of props
|
|
55
|
-
|
|
56
|
-
<table className="props-table">
|
|
57
|
-
<thead>
|
|
58
|
-
<tr>
|
|
59
|
-
<th>
|
|
60
|
-
Name
|
|
61
|
-
</th>
|
|
62
|
-
<th>
|
|
63
|
-
Type
|
|
64
|
-
</th>
|
|
65
|
-
<th>
|
|
66
|
-
Default
|
|
67
|
-
</th>
|
|
68
|
-
<th>
|
|
69
|
-
Description
|
|
70
|
-
</th>
|
|
71
|
-
</tr>
|
|
72
|
-
</thead>
|
|
73
|
-
<tbody>
|
|
74
|
-
{wrapperProps.map(row => (
|
|
75
|
-
<tr className={row.isObjectRow ? "is-object-row" : ""}>
|
|
76
|
-
<td>
|
|
77
|
-
{row.name}
|
|
78
|
-
</td>
|
|
79
|
-
<td>
|
|
80
|
-
{row.type.map(type => (<Code code={type} />))}
|
|
81
|
-
</td>
|
|
82
|
-
<td>
|
|
83
|
-
<Code code={row.defaultValue} />
|
|
84
|
-
</td>
|
|
85
|
-
<td>
|
|
86
|
-
{row.description}
|
|
87
|
-
</td>
|
|
88
|
-
</tr>
|
|
89
|
-
))}
|
|
90
|
-
</tbody>
|
|
91
|
-
|
|
92
|
-
</table>
|