react-zoom-pan-pinch 2.2.1 → 2.3.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/components/transform-component.d.ts +10 -0
- package/dist/components/transform-wrapper.d.ts +8 -0
- package/dist/constants/state.constants.d.ts +6 -0
- package/dist/core/animations/animations.constants.d.ts +16 -0
- package/dist/core/animations/animations.utils.d.ts +4 -0
- package/dist/core/bounds/bounds.types.d.ts +8 -0
- package/dist/core/bounds/bounds.utils.d.ts +15 -0
- package/dist/core/double-click/double-click.logic.d.ts +3 -0
- package/dist/core/handlers/handlers.logic.d.ts +8 -0
- package/dist/core/handlers/handlers.utils.d.ts +13 -0
- package/dist/core/instance.core.d.ts +68 -0
- package/dist/core/pan/panning.logic.d.ts +5 -0
- package/dist/core/pan/panning.utils.d.ts +10 -0
- package/dist/core/pan/velocity.logic.d.ts +5 -0
- package/dist/core/pan/velocity.utils.d.ts +5 -0
- package/dist/core/pinch/pinch.logic.d.ts +4 -0
- package/dist/core/pinch/pinch.utils.d.ts +6 -0
- package/dist/core/wheel/wheel.logic.d.ts +4 -0
- package/dist/core/wheel/wheel.utils.d.ts +7 -0
- package/dist/core/zoom/zoom.logic.d.ts +3 -0
- package/dist/core/zoom/zoom.utils.d.ts +3 -0
- package/dist/hooks/use-transform-context.d.ts +3 -0
- package/dist/index.cjs.js +270 -267
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +63 -57
- package/dist/index.esm.js +270 -267
- package/dist/index.esm.js.map +1 -1
- package/dist/models/calculations.model.d.ts +25 -0
- package/dist/models/context.model.d.ts +117 -0
- package/dist/models/helpers.model.d.ts +5 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/stories/docs/handlers.d.ts +12 -0
- package/dist/stories/docs/props.d.ts +14 -0
- package/dist/stories/examples/content-rerendering/example.d.ts +2 -0
- package/dist/stories/examples/stress/example.d.ts +2 -0
- package/dist/stories/examples/zoom-to-element/example.d.ts +2 -0
- package/dist/stories/types/args.types.d.ts +268 -0
- package/dist/stories/utils/args.utils.d.ts +3 -0
- package/dist/stories/utils/code.utils.d.ts +6 -0
- package/dist/stories/utils/controls.utils.d.ts +3 -0
- package/dist/stories/utils/index.d.ts +3 -0
- package/dist/utils/calculations.utils.d.ts +11 -0
- package/dist/utils/callback.utils.d.ts +2 -0
- package/dist/utils/context.utils.d.ts +2 -0
- package/dist/utils/event.utils.d.ts +1 -0
- package/dist/utils/helpers.utils.d.ts +2 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/state.utils.d.ts +3 -0
- package/dist/utils/styles.utils.d.ts +3 -0
- package/package.json +30 -25
- package/src/.eslintrc.json +90 -0
- package/src/components/transform-component.tsx +2 -1
- package/src/components/transform-wrapper.tsx +27 -5
- package/src/constants/state.constants.ts +0 -2
- package/src/core/animations/animations.constants.ts +14 -12
- package/src/core/animations/animations.utils.ts +15 -11
- package/src/core/bounds/bounds.utils.ts +20 -20
- package/src/core/double-click/double-click.logic.ts +6 -12
- package/src/core/handlers/handlers.logic.ts +98 -89
- package/src/core/handlers/handlers.utils.ts +22 -24
- package/src/{components/transform-context.tsx → core/instance.core.ts} +85 -118
- package/src/core/pan/panning.logic.ts +20 -19
- package/src/core/pan/panning.utils.ts +4 -7
- package/src/core/pan/velocity.logic.ts +1 -0
- package/src/core/pinch/pinch.logic.ts +4 -6
- package/src/core/pinch/pinch.utils.ts +2 -2
- package/src/core/wheel/wheel.logic.ts +1 -0
- package/src/core/wheel/wheel.utils.ts +12 -11
- package/src/core/zoom/zoom.logic.ts +29 -29
- package/src/core/zoom/zoom.utils.ts +2 -2
- package/src/hooks/use-transform-context.tsx +3 -2
- package/src/models/context.model.ts +6 -2
- package/src/stories/docs/handlers.tsx +30 -30
- package/src/stories/examples/content-rerendering/content-updating.stories.mdx +3 -0
- package/src/stories/examples/stress/example.tsx +24 -0
- package/src/stories/examples/stress/stress-test.stories.mdx +28 -0
- package/src/stories/examples/zoom-to-element/example.tsx +4 -0
- package/src/stories/utils/code.utils.tsx +1 -0
- package/src/stories/utils/controls.utils.tsx +21 -4
- package/src/stories/utils/styles.module.css +5 -0
- package/src/.eslintrc.js +0 -36
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
export declare const argsTypes: {
|
|
2
|
+
wheel: {
|
|
3
|
+
table: {
|
|
4
|
+
disable: boolean;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
"wheel.step": {
|
|
8
|
+
defaultValue: number;
|
|
9
|
+
control: {
|
|
10
|
+
type: string;
|
|
11
|
+
min: number;
|
|
12
|
+
};
|
|
13
|
+
table: {
|
|
14
|
+
defaultValue: {
|
|
15
|
+
summary: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
"wheel.disabled": {
|
|
20
|
+
defaultValue: NonNullable<boolean | undefined>;
|
|
21
|
+
control: {
|
|
22
|
+
type: string;
|
|
23
|
+
};
|
|
24
|
+
table: {
|
|
25
|
+
defaultValue: {
|
|
26
|
+
summary: string;
|
|
27
|
+
};
|
|
28
|
+
type: {
|
|
29
|
+
summary: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
"wheel.wheelDisabled": {
|
|
34
|
+
defaultValue: NonNullable<boolean | undefined>;
|
|
35
|
+
control: {
|
|
36
|
+
type: string;
|
|
37
|
+
};
|
|
38
|
+
table: {
|
|
39
|
+
defaultValue: {
|
|
40
|
+
summary: string;
|
|
41
|
+
};
|
|
42
|
+
type: {
|
|
43
|
+
summary: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
"wheel.touchPadDisabled": {
|
|
48
|
+
defaultValue: NonNullable<boolean | undefined>;
|
|
49
|
+
control: {
|
|
50
|
+
type: string;
|
|
51
|
+
};
|
|
52
|
+
table: {
|
|
53
|
+
defaultValue: {
|
|
54
|
+
summary: string;
|
|
55
|
+
};
|
|
56
|
+
type: {
|
|
57
|
+
summary: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
"wheel.activationKeys": {
|
|
62
|
+
defaultValue: import("../../models").DeepNonNullableArray<string>;
|
|
63
|
+
control: {
|
|
64
|
+
type: string;
|
|
65
|
+
};
|
|
66
|
+
table: {
|
|
67
|
+
defaultValue: {
|
|
68
|
+
summary: string;
|
|
69
|
+
};
|
|
70
|
+
type: {
|
|
71
|
+
summary: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
"wheel.excluded": {
|
|
76
|
+
defaultValue: import("../../models").DeepNonNullableArray<string>;
|
|
77
|
+
control: {
|
|
78
|
+
type: string;
|
|
79
|
+
};
|
|
80
|
+
table: {
|
|
81
|
+
defaultValue: {
|
|
82
|
+
summary: string;
|
|
83
|
+
};
|
|
84
|
+
type: {
|
|
85
|
+
summary: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
panning: {
|
|
90
|
+
table: {
|
|
91
|
+
disable: boolean;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
"panning.disabled": {
|
|
95
|
+
defaultValue: NonNullable<boolean | undefined>;
|
|
96
|
+
control: {
|
|
97
|
+
type: string;
|
|
98
|
+
};
|
|
99
|
+
table: {
|
|
100
|
+
defaultValue: {
|
|
101
|
+
summary: string;
|
|
102
|
+
};
|
|
103
|
+
type: {
|
|
104
|
+
summary: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
"panning.velocityDisabled": {
|
|
109
|
+
defaultValue: NonNullable<boolean | undefined>;
|
|
110
|
+
control: {
|
|
111
|
+
type: string;
|
|
112
|
+
};
|
|
113
|
+
table: {
|
|
114
|
+
defaultValue: {
|
|
115
|
+
summary: string;
|
|
116
|
+
};
|
|
117
|
+
type: {
|
|
118
|
+
summary: string;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
"panning.lockAxisX": {
|
|
123
|
+
defaultValue: NonNullable<boolean | undefined>;
|
|
124
|
+
control: {
|
|
125
|
+
type: string;
|
|
126
|
+
};
|
|
127
|
+
table: {
|
|
128
|
+
defaultValue: {
|
|
129
|
+
summary: string;
|
|
130
|
+
};
|
|
131
|
+
type: {
|
|
132
|
+
summary: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
"panning.lockAxisY": {
|
|
137
|
+
defaultValue: NonNullable<boolean | undefined>;
|
|
138
|
+
control: {
|
|
139
|
+
type: string;
|
|
140
|
+
};
|
|
141
|
+
table: {
|
|
142
|
+
defaultValue: {
|
|
143
|
+
summary: string;
|
|
144
|
+
};
|
|
145
|
+
type: {
|
|
146
|
+
summary: string;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
"panning.activationKeys": {
|
|
151
|
+
defaultValue: import("../../models").DeepNonNullableArray<string>;
|
|
152
|
+
control: {
|
|
153
|
+
type: string;
|
|
154
|
+
};
|
|
155
|
+
table: {
|
|
156
|
+
defaultValue: {
|
|
157
|
+
summary: string;
|
|
158
|
+
};
|
|
159
|
+
type: {
|
|
160
|
+
summary: string;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
"panning.excluded": {
|
|
165
|
+
defaultValue: import("../../models").DeepNonNullableArray<string>;
|
|
166
|
+
control: {
|
|
167
|
+
type: string;
|
|
168
|
+
};
|
|
169
|
+
table: {
|
|
170
|
+
defaultValue: {
|
|
171
|
+
summary: string;
|
|
172
|
+
};
|
|
173
|
+
type: {
|
|
174
|
+
summary: string;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
pinch: {
|
|
179
|
+
table: {
|
|
180
|
+
disable: boolean;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
"pinch.step": {
|
|
184
|
+
defaultValue: number;
|
|
185
|
+
control: {
|
|
186
|
+
type: string;
|
|
187
|
+
min: number;
|
|
188
|
+
};
|
|
189
|
+
table: {
|
|
190
|
+
defaultValue: {
|
|
191
|
+
summary: string;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
"pinch.disabled": {
|
|
196
|
+
defaultValue: NonNullable<boolean | undefined>;
|
|
197
|
+
control: {
|
|
198
|
+
type: string;
|
|
199
|
+
};
|
|
200
|
+
table: {
|
|
201
|
+
defaultValue: {
|
|
202
|
+
summary: string;
|
|
203
|
+
};
|
|
204
|
+
type: {
|
|
205
|
+
summary: string;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
"pinch.excluded": {
|
|
210
|
+
defaultValue: import("../../models").DeepNonNullableArray<string>;
|
|
211
|
+
control: {
|
|
212
|
+
type: string;
|
|
213
|
+
};
|
|
214
|
+
table: {
|
|
215
|
+
defaultValue: {
|
|
216
|
+
summary: string;
|
|
217
|
+
};
|
|
218
|
+
type: {
|
|
219
|
+
summary: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
doubleClick: {
|
|
224
|
+
table: {
|
|
225
|
+
disable: boolean;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
"doubleClick.step": {
|
|
229
|
+
defaultValue: number;
|
|
230
|
+
control: {
|
|
231
|
+
type: string;
|
|
232
|
+
min: number;
|
|
233
|
+
};
|
|
234
|
+
table: {
|
|
235
|
+
defaultValue: {
|
|
236
|
+
summary: string;
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
"doubleClick.disabled": {
|
|
241
|
+
defaultValue: NonNullable<boolean | undefined>;
|
|
242
|
+
control: {
|
|
243
|
+
type: string;
|
|
244
|
+
};
|
|
245
|
+
table: {
|
|
246
|
+
defaultValue: {
|
|
247
|
+
summary: string;
|
|
248
|
+
};
|
|
249
|
+
type: {
|
|
250
|
+
summary: string;
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
"doubleClick.excluded": {
|
|
255
|
+
defaultValue: import("../../models").DeepNonNullableArray<string>;
|
|
256
|
+
control: {
|
|
257
|
+
type: string;
|
|
258
|
+
};
|
|
259
|
+
table: {
|
|
260
|
+
defaultValue: {
|
|
261
|
+
summary: string;
|
|
262
|
+
};
|
|
263
|
+
type: {
|
|
264
|
+
summary: string;
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rounds number to given decimal
|
|
3
|
+
* eg. roundNumber(2.34343, 1) => 2.3
|
|
4
|
+
*/
|
|
5
|
+
export declare const roundNumber: (num: number, decimal: number) => number;
|
|
6
|
+
/**
|
|
7
|
+
* Checks if value is number, if not it returns default value
|
|
8
|
+
* 1# eg. checkIsNumber(2, 30) => 2
|
|
9
|
+
* 2# eg. checkIsNumber(null, 30) => 30
|
|
10
|
+
*/
|
|
11
|
+
export declare const checkIsNumber: (num: any, defaultValue: number) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makePassiveEventOption(): any;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { LibrarySetup, ReactZoomPanPinchProps, ReactZoomPanPinchState } from "../models/context.model";
|
|
2
|
+
export declare const createState: (props: ReactZoomPanPinchProps) => ReactZoomPanPinchState;
|
|
3
|
+
export declare const createSetup: (props: ReactZoomPanPinchProps) => LibrarySetup;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-zoom-pan-pinch",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Zoom and pan html elements in easy way",
|
|
5
5
|
"author": "prc5",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,51 +31,56 @@
|
|
|
31
31
|
"react-dom": "*"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@babel/core": "^7.
|
|
35
|
-
"@babel/runtime": "^7.13
|
|
34
|
+
"@babel/core": "^7.20.12",
|
|
35
|
+
"@babel/runtime": "^7.20.13",
|
|
36
36
|
"@rollup/plugin-babel": "^5.3.0",
|
|
37
37
|
"@rollup/plugin-typescript": "^8.2.1",
|
|
38
|
-
"@storybook/addon-a11y": "^6.
|
|
39
|
-
"@storybook/addon-actions": "^6.
|
|
40
|
-
"@storybook/addon-docs": "^6.
|
|
41
|
-
"@storybook/addon-essentials": "^6.
|
|
42
|
-
"@storybook/addon-links": "^6.
|
|
43
|
-
"@storybook/addon-storysource": "^6.
|
|
44
|
-
"@storybook/
|
|
45
|
-
"@storybook/
|
|
38
|
+
"@storybook/addon-a11y": "^6.5.16",
|
|
39
|
+
"@storybook/addon-actions": "^6.5.16",
|
|
40
|
+
"@storybook/addon-docs": "^6.5.16",
|
|
41
|
+
"@storybook/addon-essentials": "^6.5.16",
|
|
42
|
+
"@storybook/addon-links": "^6.5.16",
|
|
43
|
+
"@storybook/addon-storysource": "^6.5.16",
|
|
44
|
+
"@storybook/builder-webpack5": "^6.5.16",
|
|
45
|
+
"@storybook/manager-webpack5": "^6.5.16",
|
|
46
|
+
"@storybook/preset-create-react-app": "4.1.2",
|
|
47
|
+
"@storybook/react": "^6.5.16",
|
|
46
48
|
"@testing-library/react": "^11.2.6",
|
|
47
49
|
"@types/jest": "^26.0.22",
|
|
48
50
|
"@types/node": "^15.6.1",
|
|
49
51
|
"@types/react": "^17.0.3",
|
|
50
52
|
"@types/react-dom": "^17.0.3",
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
52
|
-
"@typescript-eslint/parser": "^
|
|
53
|
-
"all-contributors-cli": "^6.20.0",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
54
|
+
"@typescript-eslint/parser": "^5.28.0",
|
|
54
55
|
"babel-eslint": "9.0.0",
|
|
55
56
|
"babel-loader": "^8.2.2",
|
|
56
57
|
"cross-env": "^7.0.3",
|
|
57
|
-
"eslint": "^
|
|
58
|
-
"eslint-config-airbnb": "18.2.1",
|
|
59
|
-
"eslint-config-
|
|
60
|
-
"eslint-
|
|
61
|
-
"eslint-
|
|
62
|
-
"eslint-
|
|
63
|
-
"eslint-plugin-
|
|
64
|
-
"eslint-plugin-
|
|
58
|
+
"eslint": "^8.17.0",
|
|
59
|
+
"eslint-config-airbnb": "^18.2.1",
|
|
60
|
+
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
61
|
+
"eslint-config-next": "12.1.6",
|
|
62
|
+
"eslint-config-prettier": "^8.5.0",
|
|
63
|
+
"eslint-config-react-app": "^7.0.1",
|
|
64
|
+
"eslint-plugin-import": "^2.26.0",
|
|
65
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
66
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
67
|
+
"eslint-plugin-react": "^7.30.0",
|
|
68
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
65
69
|
"gh-pages": "^3.1.0",
|
|
66
70
|
"install-peers-cli": "^2.2.0",
|
|
67
71
|
"postcss": "^8.2.13",
|
|
68
72
|
"prism-react-renderer": "^1.2.1",
|
|
69
|
-
"react-scripts": "
|
|
73
|
+
"react-scripts": "5.0.1",
|
|
70
74
|
"rollup": "^2.46.0",
|
|
71
75
|
"rollup-plugin-delete": "^2.0.0",
|
|
72
76
|
"rollup-plugin-dts": "^3.0.2",
|
|
73
77
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
74
78
|
"rollup-plugin-postcss": "^4.0.0",
|
|
75
79
|
"source-map-loader": "^2.0.1",
|
|
76
|
-
"ts-loader": "^
|
|
80
|
+
"ts-loader": "^9.4.2",
|
|
77
81
|
"typescript": "^4.2.3",
|
|
78
|
-
"webpack
|
|
82
|
+
"webpack": "5",
|
|
83
|
+
"webpack-cli": "^5.0.1"
|
|
79
84
|
},
|
|
80
85
|
"files": [
|
|
81
86
|
"dist",
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"parser": "@typescript-eslint/parser",
|
|
4
|
+
"parserOptions": {
|
|
5
|
+
"ecmaVersion": 11,
|
|
6
|
+
"ecmaFeatures": {
|
|
7
|
+
"jsx": true
|
|
8
|
+
},
|
|
9
|
+
"project": "./tsconfig.json"
|
|
10
|
+
},
|
|
11
|
+
"settings": {
|
|
12
|
+
"import/resolver": {
|
|
13
|
+
"node": {
|
|
14
|
+
"moduleDirectory": ["node_modules", "src/"]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"react": {
|
|
18
|
+
"pragma": "React",
|
|
19
|
+
"version": "detect"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"plugins": ["react", "react-hooks"],
|
|
23
|
+
"extends": [
|
|
24
|
+
"eslint:recommended",
|
|
25
|
+
"plugin:react-hooks/recommended",
|
|
26
|
+
"prettier",
|
|
27
|
+
"plugin:react/recommended",
|
|
28
|
+
"plugin:@typescript-eslint/recommended",
|
|
29
|
+
"plugin:import/typescript",
|
|
30
|
+
"airbnb",
|
|
31
|
+
"airbnb-typescript",
|
|
32
|
+
"plugin:prettier/recommended"
|
|
33
|
+
],
|
|
34
|
+
"rules": {
|
|
35
|
+
"react-hooks/rules-of-hooks": "error",
|
|
36
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
37
|
+
"react/prop-types": "off",
|
|
38
|
+
"react/jsx-uses-react": "error",
|
|
39
|
+
"react/jsx-uses-vars": "error",
|
|
40
|
+
"no-console": ["error", { "allow": ["warn", "error"] }],
|
|
41
|
+
"react/react-in-jsx-scope": "off",
|
|
42
|
+
"react/display-name": 0,
|
|
43
|
+
"import/no-extraneous-dependencies": 0,
|
|
44
|
+
"import/prefer-default-export": 0,
|
|
45
|
+
"import/no-cycle": 0,
|
|
46
|
+
"@typescript-eslint/no-explicit-any": 0,
|
|
47
|
+
"@typescript-eslint/lines-between-class-members": "off",
|
|
48
|
+
"prettier/prettier": ["error"],
|
|
49
|
+
"consistent-return": 0,
|
|
50
|
+
"@typescript-eslint/no-throw-literal": 0,
|
|
51
|
+
"no-underscore-dangle": 0,
|
|
52
|
+
"react/jsx-props-no-spreading": 0,
|
|
53
|
+
"react/function-component-definition": 0,
|
|
54
|
+
"testing-library/render-result-naming-convention": "off",
|
|
55
|
+
"import/order": [
|
|
56
|
+
"error",
|
|
57
|
+
{
|
|
58
|
+
"groups": [
|
|
59
|
+
["builtin", "external"],
|
|
60
|
+
["internal", "parent", "sibling", "index"]
|
|
61
|
+
],
|
|
62
|
+
"pathGroups": [
|
|
63
|
+
{ "pattern": "assets/**", "group": "sibling", "position": "after" },
|
|
64
|
+
{
|
|
65
|
+
"pattern": "@external/**/*.css",
|
|
66
|
+
"group": "sibling",
|
|
67
|
+
"position": "after"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"pattern": "*.css",
|
|
71
|
+
"group": "index",
|
|
72
|
+
"patternOptions": { "matchBase": true },
|
|
73
|
+
"position": "after"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"warnOnUnassignedImports": true,
|
|
77
|
+
"pathGroupsExcludedImportTypes": ["css"],
|
|
78
|
+
"newlines-between": "always"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"overrides": [
|
|
83
|
+
{
|
|
84
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
85
|
+
"rules": {
|
|
86
|
+
"testing-library/render-result-naming-convention": "off"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/* eslint-disable react/require-default-props */
|
|
1
2
|
import React, { useContext, useEffect, useRef } from "react";
|
|
2
3
|
|
|
3
|
-
import { Context } from "./transform-
|
|
4
|
+
import { Context } from "./transform-wrapper";
|
|
4
5
|
|
|
5
6
|
import styles from "./transform-component.module.css";
|
|
6
7
|
|
|
@@ -1,17 +1,39 @@
|
|
|
1
|
-
import React, { useImperativeHandle,
|
|
1
|
+
import React, { useImperativeHandle, useMemo, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { ZoomPanPinch } from "../core/instance.core";
|
|
2
4
|
import { ReactZoomPanPinchProps, ReactZoomPanPinchRef } from "../models";
|
|
3
|
-
import {
|
|
5
|
+
import { getContext } from "../utils";
|
|
6
|
+
import { contextInitialState } from "../constants/state.constants";
|
|
7
|
+
|
|
8
|
+
export const Context = React.createContext(contextInitialState);
|
|
4
9
|
|
|
5
10
|
export const TransformWrapper = React.forwardRef(
|
|
6
11
|
(
|
|
7
12
|
props: Omit<ReactZoomPanPinchProps, "ref">,
|
|
8
13
|
ref: React.Ref<ReactZoomPanPinchRef>,
|
|
9
14
|
) => {
|
|
10
|
-
const
|
|
15
|
+
const { children } = props;
|
|
16
|
+
const instance = useRef(new ZoomPanPinch(props)).current;
|
|
17
|
+
|
|
18
|
+
const content = useMemo(() => {
|
|
19
|
+
if (typeof children === "function") {
|
|
20
|
+
return children(getContext(instance));
|
|
21
|
+
}
|
|
22
|
+
return children;
|
|
23
|
+
}, [children, instance]);
|
|
24
|
+
|
|
25
|
+
const value = useMemo(() => {
|
|
26
|
+
return {
|
|
27
|
+
...instance.transformState,
|
|
28
|
+
setComponents: instance.init,
|
|
29
|
+
contextInstance: instance,
|
|
30
|
+
};
|
|
31
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
+
}, [JSON.stringify(instance.transformState)]);
|
|
11
33
|
|
|
12
|
-
useImperativeHandle(ref, () =>
|
|
34
|
+
useImperativeHandle(ref, () => getContext(instance), [instance]);
|
|
13
35
|
|
|
14
|
-
return <
|
|
36
|
+
return <Context.Provider value={value}>{content}</Context.Provider>;
|
|
15
37
|
},
|
|
16
38
|
);
|
|
17
39
|
|
|
@@ -1,52 +1,54 @@
|
|
|
1
|
+
/* eslint-disable no-plusplus */
|
|
2
|
+
/* eslint-disable no-param-reassign */
|
|
1
3
|
/**
|
|
2
4
|
* Functions should return denominator of the target value, which is the next animation step.
|
|
3
5
|
* t is a value from 0 to 1, reflecting the percentage of animation status.
|
|
4
6
|
*/
|
|
5
|
-
const easeOut =
|
|
7
|
+
const easeOut = (t: number): number => {
|
|
6
8
|
return -Math.cos(t * Math.PI) / 2 + 0.5;
|
|
7
9
|
};
|
|
8
10
|
// linear
|
|
9
|
-
const linear =
|
|
11
|
+
const linear = (t: number): number => {
|
|
10
12
|
return t;
|
|
11
13
|
};
|
|
12
14
|
// accelerating from zero velocity
|
|
13
|
-
const easeInQuad =
|
|
15
|
+
const easeInQuad = (t: number): number => {
|
|
14
16
|
return t * t;
|
|
15
17
|
};
|
|
16
18
|
// decelerating to zero velocity
|
|
17
|
-
const easeOutQuad =
|
|
19
|
+
const easeOutQuad = (t: number): number => {
|
|
18
20
|
return t * (2 - t);
|
|
19
21
|
};
|
|
20
22
|
// acceleration until halfway, then deceleration
|
|
21
|
-
const easeInOutQuad =
|
|
23
|
+
const easeInOutQuad = (t: number): number => {
|
|
22
24
|
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
23
25
|
};
|
|
24
26
|
// accelerating from zero velocity
|
|
25
|
-
const easeInCubic =
|
|
27
|
+
const easeInCubic = (t: number): number => {
|
|
26
28
|
return t * t * t;
|
|
27
29
|
};
|
|
28
30
|
// decelerating to zero velocity
|
|
29
|
-
const easeOutCubic =
|
|
31
|
+
const easeOutCubic = (t: number): number => {
|
|
30
32
|
return --t * t * t + 1;
|
|
31
33
|
};
|
|
32
34
|
// acceleration until halfway, then deceleration
|
|
33
|
-
const easeInOutCubic =
|
|
35
|
+
const easeInOutCubic = (t: number): number => {
|
|
34
36
|
return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
|
|
35
37
|
};
|
|
36
38
|
// accelerating from zero velocity
|
|
37
|
-
const easeInQuart =
|
|
39
|
+
const easeInQuart = (t: number): number => {
|
|
38
40
|
return t * t * t * t;
|
|
39
41
|
};
|
|
40
42
|
// decelerating to zero velocity
|
|
41
|
-
const easeOutQuart =
|
|
43
|
+
const easeOutQuart = (t: number): number => {
|
|
42
44
|
return 1 - --t * t * t * t;
|
|
43
45
|
};
|
|
44
46
|
// acceleration until halfway, then deceleration
|
|
45
|
-
const easeInOutQuart =
|
|
47
|
+
const easeInOutQuart = (t: number): number => {
|
|
46
48
|
return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t;
|
|
47
49
|
};
|
|
48
50
|
// accelerating from zero velocity
|
|
49
|
-
const easeInQuint =
|
|
51
|
+
const easeInQuint = (t: number): number => {
|
|
50
52
|
return t * t * t * t * t;
|
|
51
53
|
};
|
|
52
54
|
// decelerating to zero velocity
|