react-zoom-pan-pinch 2.1.3 → 2.2.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/README.md +43 -0
- package/dist/index.cjs.js +60 -34
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.esm.js +60 -34
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -4
- package/src/.eslintrc.js +36 -0
- package/src/components/transform-component.module.css +30 -0
- package/src/components/transform-component.tsx +52 -0
- package/src/components/transform-context.tsx +493 -0
- package/src/components/transform-wrapper.tsx +18 -0
- package/src/constants/state.constants.ts +88 -0
- package/src/core/animations/animations.constants.ts +76 -0
- package/src/core/animations/animations.utils.ts +109 -0
- package/src/core/bounds/bounds.types.ts +8 -0
- package/src/core/bounds/bounds.utils.ts +157 -0
- package/src/core/double-click/double-click.logic.ts +75 -0
- package/src/core/handlers/handlers.logic.ts +112 -0
- package/src/core/handlers/handlers.utils.ts +202 -0
- package/src/core/pan/panning.logic.ts +99 -0
- package/src/core/pan/panning.utils.ts +199 -0
- package/src/core/pan/velocity.logic.ts +148 -0
- package/src/core/pan/velocity.utils.ts +79 -0
- package/src/core/pinch/pinch.logic.ts +83 -0
- package/src/core/pinch/pinch.utils.ts +88 -0
- package/src/core/wheel/wheel.logic.ts +118 -0
- package/src/core/wheel/wheel.utils.ts +121 -0
- package/src/core/zoom/zoom.logic.ts +69 -0
- package/src/core/zoom/zoom.utils.ts +58 -0
- package/src/hooks/use-transform-context.tsx +16 -0
- package/src/index.ts +6 -0
- package/src/models/calculations.model.ts +26 -0
- package/src/models/context.model.ts +179 -0
- package/src/models/helpers.model.ts +15 -0
- package/src/models/index.ts +3 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/stories/assets/big-image.jpeg +0 -0
- package/src/stories/assets/medium-image.jpg +0 -0
- package/src/stories/assets/small-image.jpg +0 -0
- package/src/stories/assets/svg-example.svg +14 -0
- package/src/stories/docs/Introduction.stories.mdx +97 -0
- package/src/stories/docs/handlers.stories.mdx +48 -0
- package/src/stories/docs/handlers.tsx +107 -0
- package/src/stories/docs/props.stories.mdx +92 -0
- package/src/stories/docs/props.tsx +490 -0
- package/src/stories/examples/content/content.stories.mdx +122 -0
- package/src/stories/examples/content-rerendering/content-updating.stories.mdx +42 -0
- package/src/stories/examples/content-rerendering/example.tsx +74 -0
- package/src/stories/examples/controls/controls.stories.mdx +71 -0
- package/src/stories/examples/image-big/image-big.stories.mdx +44 -0
- package/src/stories/examples/image-medium/image-medium.stories.mdx +42 -0
- package/src/stories/examples/image-small/image-small.stories.mdx +42 -0
- package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +47 -0
- package/src/stories/examples/zoom-to-element/example.tsx +91 -0
- package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +28 -0
- package/src/stories/types/args.types.ts +201 -0
- package/src/stories/utils/args.utils.ts +34 -0
- package/src/stories/utils/code.utils.tsx +21 -0
- package/src/stories/utils/controls.utils.tsx +26 -0
- package/src/stories/utils/index.ts +3 -0
- package/src/stories/utils/styles.module.css +29 -0
- package/src/styles.css +8 -0
- package/src/typings.d.ts +10 -0
- package/src/utils/calculations.utils.ts +16 -0
- package/src/utils/callback.utils.ts +11 -0
- package/src/utils/context.utils.ts +27 -0
- package/src/utils/event.utils.ts +22 -0
- package/src/utils/helpers.utils.ts +27 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/state.utils.ts +40 -0
- package/src/utils/styles.utils.ts +35 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { TransformContext } from "../components/transform-context";
|
|
4
|
+
import { animations } from "../core/animations/animations.constants";
|
|
5
|
+
import { DeepNonNullable } from "./helpers.model";
|
|
6
|
+
import {
|
|
7
|
+
zoomIn,
|
|
8
|
+
zoomToElement,
|
|
9
|
+
centerView,
|
|
10
|
+
resetTransform,
|
|
11
|
+
setTransform,
|
|
12
|
+
zoomOut,
|
|
13
|
+
} from "../core/handlers/handlers.logic";
|
|
14
|
+
|
|
15
|
+
export type ReactZoomPanPinchContext = typeof TransformContext.prototype;
|
|
16
|
+
|
|
17
|
+
export type ReactZoomPanPinchRef = {
|
|
18
|
+
instance: ReactZoomPanPinchContext;
|
|
19
|
+
state: ReactZoomPanPinchState;
|
|
20
|
+
} & ReactZoomPanPinchHandlers;
|
|
21
|
+
|
|
22
|
+
export type ReactZoomPanPinchState = {
|
|
23
|
+
previousScale: number;
|
|
24
|
+
scale: number;
|
|
25
|
+
positionX: number;
|
|
26
|
+
positionY: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type ReactZoomPanPinchHandlers = {
|
|
30
|
+
zoomIn: ReturnType<typeof zoomIn>;
|
|
31
|
+
zoomOut: ReturnType<typeof zoomOut>;
|
|
32
|
+
setTransform: ReturnType<typeof setTransform>;
|
|
33
|
+
resetTransform: ReturnType<typeof resetTransform>;
|
|
34
|
+
centerView: ReturnType<typeof centerView>;
|
|
35
|
+
zoomToElement: ReturnType<typeof zoomToElement>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type ReactZoomPanPinchProps = {
|
|
39
|
+
children?: React.ReactNode | ((ref: ReactZoomPanPinchRef) => React.ReactNode);
|
|
40
|
+
ref?: React.Ref<ReactZoomPanPinchRef>;
|
|
41
|
+
initialScale?: number;
|
|
42
|
+
initialPositionX?: number;
|
|
43
|
+
initialPositionY?: number;
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
minPositionX?: null | number;
|
|
46
|
+
maxPositionX?: null | number;
|
|
47
|
+
minPositionY?: null | number;
|
|
48
|
+
maxPositionY?: null | number;
|
|
49
|
+
minScale?: number;
|
|
50
|
+
maxScale?: number;
|
|
51
|
+
limitToBounds?: boolean;
|
|
52
|
+
centerZoomedOut?: boolean;
|
|
53
|
+
centerOnInit?: boolean;
|
|
54
|
+
disablePadding?: boolean;
|
|
55
|
+
wheel?: {
|
|
56
|
+
step?: number;
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
wheelDisabled?: boolean;
|
|
59
|
+
touchPadDisabled?: boolean;
|
|
60
|
+
activationKeys?: string[];
|
|
61
|
+
excluded?: string[];
|
|
62
|
+
};
|
|
63
|
+
panning?: {
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
velocityDisabled?: boolean;
|
|
66
|
+
lockAxisX?: boolean;
|
|
67
|
+
lockAxisY?: boolean;
|
|
68
|
+
activationKeys?: string[];
|
|
69
|
+
excluded?: string[];
|
|
70
|
+
};
|
|
71
|
+
pinch?: {
|
|
72
|
+
step?: number;
|
|
73
|
+
disabled?: boolean;
|
|
74
|
+
excluded?: string[];
|
|
75
|
+
};
|
|
76
|
+
doubleClick?: {
|
|
77
|
+
disabled?: boolean;
|
|
78
|
+
step?: number;
|
|
79
|
+
mode?: "zoomIn" | "zoomOut" | "reset";
|
|
80
|
+
animationTime?: number;
|
|
81
|
+
animationType?: keyof typeof animations;
|
|
82
|
+
excluded?: string[];
|
|
83
|
+
};
|
|
84
|
+
zoomAnimation?: {
|
|
85
|
+
disabled?: boolean;
|
|
86
|
+
size?: number;
|
|
87
|
+
animationTime?: number;
|
|
88
|
+
animationType?: keyof typeof animations;
|
|
89
|
+
};
|
|
90
|
+
alignmentAnimation?: {
|
|
91
|
+
disabled?: boolean;
|
|
92
|
+
sizeX?: number;
|
|
93
|
+
sizeY?: number;
|
|
94
|
+
animationTime?: number;
|
|
95
|
+
velocityAlignmentTime?: number;
|
|
96
|
+
animationType?: keyof typeof animations;
|
|
97
|
+
};
|
|
98
|
+
velocityAnimation?: {
|
|
99
|
+
disabled?: boolean;
|
|
100
|
+
sensitivity?: number;
|
|
101
|
+
animationTime?: number;
|
|
102
|
+
animationType?: keyof typeof animations;
|
|
103
|
+
equalToMove?: boolean;
|
|
104
|
+
};
|
|
105
|
+
onWheelStart?: (ref: ReactZoomPanPinchRef, event: WheelEvent) => void;
|
|
106
|
+
onWheel?: (ref: ReactZoomPanPinchRef, event: WheelEvent) => void;
|
|
107
|
+
onWheelStop?: (ref: ReactZoomPanPinchRef, event: WheelEvent) => void;
|
|
108
|
+
onPanningStart?: (
|
|
109
|
+
ref: ReactZoomPanPinchRef,
|
|
110
|
+
event: TouchEvent | MouseEvent,
|
|
111
|
+
) => void;
|
|
112
|
+
onPanning?: (
|
|
113
|
+
ref: ReactZoomPanPinchRef,
|
|
114
|
+
event: TouchEvent | MouseEvent,
|
|
115
|
+
) => void;
|
|
116
|
+
onPanningStop?: (
|
|
117
|
+
ref: ReactZoomPanPinchRef,
|
|
118
|
+
event: TouchEvent | MouseEvent,
|
|
119
|
+
) => void;
|
|
120
|
+
onPinchingStart?: (ref: ReactZoomPanPinchRef, event: TouchEvent) => void;
|
|
121
|
+
onPinching?: (ref: ReactZoomPanPinchRef, event: TouchEvent) => void;
|
|
122
|
+
onPinchingStop?: (ref: ReactZoomPanPinchRef, event: TouchEvent) => void;
|
|
123
|
+
onZoomStart?: (
|
|
124
|
+
ref: ReactZoomPanPinchRef,
|
|
125
|
+
event: TouchEvent | MouseEvent,
|
|
126
|
+
) => void;
|
|
127
|
+
onZoom?: (ref: ReactZoomPanPinchRef, event: TouchEvent | MouseEvent) => void;
|
|
128
|
+
onZoomStop?: (
|
|
129
|
+
ref: ReactZoomPanPinchRef,
|
|
130
|
+
event: TouchEvent | MouseEvent,
|
|
131
|
+
) => void;
|
|
132
|
+
onTransformed?: (
|
|
133
|
+
ref: ReactZoomPanPinchRef,
|
|
134
|
+
state: { scale: number; positionX: number; positionY: number },
|
|
135
|
+
) => void;
|
|
136
|
+
onInit?: (ref: ReactZoomPanPinchRef) => void;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export type ReactZoomPanPinchComponentHelpers = {
|
|
140
|
+
setComponents: (wrapper: HTMLDivElement, content: HTMLDivElement) => void;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export type LibrarySetup = Pick<
|
|
144
|
+
ReactZoomPanPinchProps,
|
|
145
|
+
"minPositionX" | "maxPositionX" | "minPositionY" | "maxPositionY"
|
|
146
|
+
> &
|
|
147
|
+
DeepNonNullable<
|
|
148
|
+
Omit<
|
|
149
|
+
ReactZoomPanPinchProps,
|
|
150
|
+
| "ref"
|
|
151
|
+
| "initialScale"
|
|
152
|
+
| "initialPositionX"
|
|
153
|
+
| "initialPositionY"
|
|
154
|
+
| "minPositionX"
|
|
155
|
+
| "maxPositionX"
|
|
156
|
+
| "minPositionY"
|
|
157
|
+
| "maxPositionY"
|
|
158
|
+
| "children"
|
|
159
|
+
| "defaultPositionX"
|
|
160
|
+
| "defaultPositionY"
|
|
161
|
+
| "defaultScale"
|
|
162
|
+
| "wrapperClass"
|
|
163
|
+
| "contentClass"
|
|
164
|
+
| "onWheelStart"
|
|
165
|
+
| "onWheel"
|
|
166
|
+
| "onWheelStop"
|
|
167
|
+
| "onPanningStart"
|
|
168
|
+
| "onPanning"
|
|
169
|
+
| "onPanningStop"
|
|
170
|
+
| "onPinchingStart"
|
|
171
|
+
| "onPinching"
|
|
172
|
+
| "onPinchingStop"
|
|
173
|
+
| "onZoomStart"
|
|
174
|
+
| "onZoom"
|
|
175
|
+
| "onZoomStop"
|
|
176
|
+
| "onTransformed"
|
|
177
|
+
| "onInit"
|
|
178
|
+
>
|
|
179
|
+
>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
|
+
|
|
3
|
+
export type DeepNonNullable<T> = T extends (...args: any[]) => any
|
|
4
|
+
? T
|
|
5
|
+
: T extends any[]
|
|
6
|
+
? DeepNonNullableArray<T[number]>
|
|
7
|
+
: T extends object
|
|
8
|
+
? DeepNonNullableObject<T>
|
|
9
|
+
: T;
|
|
10
|
+
|
|
11
|
+
export type DeepNonNullableArray<T> = Array<DeepNonNullable<NonNullable<T>>>;
|
|
12
|
+
|
|
13
|
+
export type DeepNonNullableObject<T> = {
|
|
14
|
+
[P in keyof T]-?: DeepNonNullable<NonNullable<T[P]>>;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="react-scripts" />
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
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>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="Docs/Introduction" />
|
|
4
|
+
|
|
5
|
+
# React-zoom-pan-pinch
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/react-zoom-pan-pinch)
|
|
8
|
+

|
|
9
|
+
[](https://standardjs.com)
|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
> Super fast and light react npm package for zooming, panning and pinching html
|
|
15
|
+
> elements in easy way
|
|
16
|
+
|
|
17
|
+
<br />
|
|
18
|
+
<br />
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- 🚀 Fast and easy to use
|
|
23
|
+
- 🏭 Light, without external dependencies
|
|
24
|
+
- 💎 Mobile gestures, touchpad gestures and desktop mouse events support
|
|
25
|
+
- 🎁 Powerful context usage, which gives you a lot of freedom
|
|
26
|
+
- 🔧 Highly customizable
|
|
27
|
+
- 👑 Animations and many options
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install --save react-zoom-pan-pinch
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
or
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
yarn add react-zoom-pan-pinch
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
```jsx
|
|
44
|
+
import React, { Component } from "react";
|
|
45
|
+
|
|
46
|
+
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
|
|
47
|
+
|
|
48
|
+
class Example extends Component {
|
|
49
|
+
render() {
|
|
50
|
+
return (
|
|
51
|
+
<TransformWrapper>
|
|
52
|
+
<TransformComponent>
|
|
53
|
+
<img src="image.jpg" alt="test" />
|
|
54
|
+
</TransformComponent>
|
|
55
|
+
</TransformWrapper>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
or
|
|
62
|
+
|
|
63
|
+
```jsx
|
|
64
|
+
import React, { Component } from "react";
|
|
65
|
+
|
|
66
|
+
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
|
|
67
|
+
|
|
68
|
+
class Example extends Component {
|
|
69
|
+
render() {
|
|
70
|
+
return (
|
|
71
|
+
<TransformWrapper
|
|
72
|
+
initialScale={1}
|
|
73
|
+
initialPositionX={200}
|
|
74
|
+
initialPositionY={100}
|
|
75
|
+
>
|
|
76
|
+
{({ zoomIn, zoomOut, resetTransform, ...rest }) => (
|
|
77
|
+
<React.Fragment>
|
|
78
|
+
<div className="tools">
|
|
79
|
+
<button onClick={() => zoomIn()}>+</button>
|
|
80
|
+
<button onClick={() => zoomOut()}>-</button>
|
|
81
|
+
<button onClick={() => resetTransform()}>x</button>
|
|
82
|
+
</div>
|
|
83
|
+
<TransformComponent>
|
|
84
|
+
<img src="image.jpg" alt="test" />
|
|
85
|
+
<div>Example text</div>
|
|
86
|
+
</TransformComponent>
|
|
87
|
+
</React.Fragment>
|
|
88
|
+
)}
|
|
89
|
+
</TransformWrapper>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT © [prc5](https://github.com/prc5)
|
|
@@ -0,0 +1,48 @@
|
|
|
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>
|
|
@@ -0,0 +1,107 @@
|
|
|
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 getHandlersTable = (): ControlsFnOptionsType[] => {
|
|
20
|
+
return Object.keys(handlersTable).reduce<ControlsFnOptionsType[]>(
|
|
21
|
+
(acc, key) => {
|
|
22
|
+
if (Array.isArray(handlersTable[key]?.type)) {
|
|
23
|
+
acc.push({
|
|
24
|
+
...handlersTable[key],
|
|
25
|
+
name: key,
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
Object.keys(handlersTable[key]).forEach((prop) => {
|
|
29
|
+
acc.push({
|
|
30
|
+
...handlersTable[key][prop],
|
|
31
|
+
isObjectRow: key === prop,
|
|
32
|
+
name:
|
|
33
|
+
key === prop ? (
|
|
34
|
+
<b>{prop}</b>
|
|
35
|
+
) : (
|
|
36
|
+
<>
|
|
37
|
+
{key}.<b>{prop}</b>
|
|
38
|
+
</>
|
|
39
|
+
),
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return acc;
|
|
44
|
+
},
|
|
45
|
+
[],
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const handlersTable: ComponentProps = {
|
|
50
|
+
zoomIn: {
|
|
51
|
+
type: ["function(step, animationTime, animationName)"],
|
|
52
|
+
parameters: [
|
|
53
|
+
"step: number = 0.5",
|
|
54
|
+
"animationTime: number = 300",
|
|
55
|
+
"animationName: string = easeOut",
|
|
56
|
+
],
|
|
57
|
+
description: "Function used for zoom in button",
|
|
58
|
+
},
|
|
59
|
+
zoomOut: {
|
|
60
|
+
type: ["function(step, animationTime, animationName)"],
|
|
61
|
+
parameters: [
|
|
62
|
+
"step: number = 0.5",
|
|
63
|
+
"animationTime: number = 300",
|
|
64
|
+
"animationName: string = easeOut",
|
|
65
|
+
],
|
|
66
|
+
description: "Function used for zoom out button",
|
|
67
|
+
},
|
|
68
|
+
setTransform: {
|
|
69
|
+
type: ["function(x, y, scale, animationTime, animationName)"],
|
|
70
|
+
parameters: [
|
|
71
|
+
"x: number",
|
|
72
|
+
"y: number",
|
|
73
|
+
"scale: number",
|
|
74
|
+
"animationTime: number = 300",
|
|
75
|
+
"animationName: string = easeOut",
|
|
76
|
+
],
|
|
77
|
+
description: "Function used for custom transformation animation",
|
|
78
|
+
},
|
|
79
|
+
resetTransform: {
|
|
80
|
+
type: ["function(animationTime, animationName)"],
|
|
81
|
+
parameters: [
|
|
82
|
+
"animationTime: number = 300",
|
|
83
|
+
"animationName: string = easeOut",
|
|
84
|
+
],
|
|
85
|
+
description: "Function used for reset button",
|
|
86
|
+
},
|
|
87
|
+
centerView: {
|
|
88
|
+
type: ["function(scale, animationTime, animationName)"],
|
|
89
|
+
parameters: [
|
|
90
|
+
"scale: number = undefined",
|
|
91
|
+
"animationTime: number = 300",
|
|
92
|
+
"animationName: string = easeOut",
|
|
93
|
+
],
|
|
94
|
+
description: "Function used for centering the content component",
|
|
95
|
+
},
|
|
96
|
+
zoomToElement: {
|
|
97
|
+
type: ["function(node, customZoom, animationTime, animationName)"],
|
|
98
|
+
parameters: [
|
|
99
|
+
"node: HTMLElement | string",
|
|
100
|
+
"customScale: number = undefined",
|
|
101
|
+
"animationTime: number = 300",
|
|
102
|
+
"animationName: string = easeOut",
|
|
103
|
+
],
|
|
104
|
+
description:
|
|
105
|
+
"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.",
|
|
106
|
+
},
|
|
107
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
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>
|