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.
Files changed (81) hide show
  1. package/dist/components/transform-component.d.ts +10 -0
  2. package/dist/components/transform-wrapper.d.ts +8 -0
  3. package/dist/constants/state.constants.d.ts +6 -0
  4. package/dist/core/animations/animations.constants.d.ts +16 -0
  5. package/dist/core/animations/animations.utils.d.ts +4 -0
  6. package/dist/core/bounds/bounds.types.d.ts +8 -0
  7. package/dist/core/bounds/bounds.utils.d.ts +15 -0
  8. package/dist/core/double-click/double-click.logic.d.ts +3 -0
  9. package/dist/core/handlers/handlers.logic.d.ts +8 -0
  10. package/dist/core/handlers/handlers.utils.d.ts +13 -0
  11. package/dist/core/instance.core.d.ts +68 -0
  12. package/dist/core/pan/panning.logic.d.ts +5 -0
  13. package/dist/core/pan/panning.utils.d.ts +10 -0
  14. package/dist/core/pan/velocity.logic.d.ts +5 -0
  15. package/dist/core/pan/velocity.utils.d.ts +5 -0
  16. package/dist/core/pinch/pinch.logic.d.ts +4 -0
  17. package/dist/core/pinch/pinch.utils.d.ts +6 -0
  18. package/dist/core/wheel/wheel.logic.d.ts +4 -0
  19. package/dist/core/wheel/wheel.utils.d.ts +7 -0
  20. package/dist/core/zoom/zoom.logic.d.ts +3 -0
  21. package/dist/core/zoom/zoom.utils.d.ts +3 -0
  22. package/dist/hooks/use-transform-context.d.ts +3 -0
  23. package/dist/index.cjs.js +270 -267
  24. package/dist/index.cjs.js.map +1 -1
  25. package/dist/index.d.ts +63 -57
  26. package/dist/index.esm.js +270 -267
  27. package/dist/index.esm.js.map +1 -1
  28. package/dist/models/calculations.model.d.ts +25 -0
  29. package/dist/models/context.model.d.ts +117 -0
  30. package/dist/models/helpers.model.d.ts +5 -0
  31. package/dist/models/index.d.ts +3 -0
  32. package/dist/stories/docs/handlers.d.ts +12 -0
  33. package/dist/stories/docs/props.d.ts +14 -0
  34. package/dist/stories/examples/content-rerendering/example.d.ts +2 -0
  35. package/dist/stories/examples/stress/example.d.ts +2 -0
  36. package/dist/stories/examples/zoom-to-element/example.d.ts +2 -0
  37. package/dist/stories/types/args.types.d.ts +268 -0
  38. package/dist/stories/utils/args.utils.d.ts +3 -0
  39. package/dist/stories/utils/code.utils.d.ts +6 -0
  40. package/dist/stories/utils/controls.utils.d.ts +3 -0
  41. package/dist/stories/utils/index.d.ts +3 -0
  42. package/dist/utils/calculations.utils.d.ts +11 -0
  43. package/dist/utils/callback.utils.d.ts +2 -0
  44. package/dist/utils/context.utils.d.ts +2 -0
  45. package/dist/utils/event.utils.d.ts +1 -0
  46. package/dist/utils/helpers.utils.d.ts +2 -0
  47. package/dist/utils/index.d.ts +7 -0
  48. package/dist/utils/state.utils.d.ts +3 -0
  49. package/dist/utils/styles.utils.d.ts +3 -0
  50. package/package.json +30 -25
  51. package/src/.eslintrc.json +90 -0
  52. package/src/components/transform-component.tsx +2 -1
  53. package/src/components/transform-wrapper.tsx +27 -5
  54. package/src/constants/state.constants.ts +0 -2
  55. package/src/core/animations/animations.constants.ts +14 -12
  56. package/src/core/animations/animations.utils.ts +15 -11
  57. package/src/core/bounds/bounds.utils.ts +20 -20
  58. package/src/core/double-click/double-click.logic.ts +6 -12
  59. package/src/core/handlers/handlers.logic.ts +98 -89
  60. package/src/core/handlers/handlers.utils.ts +22 -24
  61. package/src/{components/transform-context.tsx → core/instance.core.ts} +85 -118
  62. package/src/core/pan/panning.logic.ts +20 -19
  63. package/src/core/pan/panning.utils.ts +4 -7
  64. package/src/core/pan/velocity.logic.ts +1 -0
  65. package/src/core/pinch/pinch.logic.ts +4 -6
  66. package/src/core/pinch/pinch.utils.ts +2 -2
  67. package/src/core/wheel/wheel.logic.ts +1 -0
  68. package/src/core/wheel/wheel.utils.ts +12 -11
  69. package/src/core/zoom/zoom.logic.ts +29 -29
  70. package/src/core/zoom/zoom.utils.ts +2 -2
  71. package/src/hooks/use-transform-context.tsx +3 -2
  72. package/src/models/context.model.ts +6 -2
  73. package/src/stories/docs/handlers.tsx +30 -30
  74. package/src/stories/examples/content-rerendering/content-updating.stories.mdx +3 -0
  75. package/src/stories/examples/stress/example.tsx +24 -0
  76. package/src/stories/examples/stress/stress-test.stories.mdx +28 -0
  77. package/src/stories/examples/zoom-to-element/example.tsx +4 -0
  78. package/src/stories/utils/code.utils.tsx +1 -0
  79. package/src/stories/utils/controls.utils.tsx +21 -4
  80. package/src/stories/utils/styles.module.css +5 -0
  81. 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,3 @@
1
+ export declare const normalizeArgs: (args: {
2
+ [key: string]: any;
3
+ }) => any;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ type Props = {
3
+ code: string;
4
+ };
5
+ export declare const Code: React.FC<Props>;
6
+ export {};
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { ReactZoomPanPinchRef } from "../../models/context.model";
3
+ export declare const Controls: React.FC<ReactZoomPanPinchRef>;
@@ -0,0 +1,3 @@
1
+ export * from "./args.utils";
2
+ export * from "./code.utils";
3
+ export * from "./controls.utils";
@@ -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,2 @@
1
+ import { ReactZoomPanPinchRef } from "../models";
2
+ export declare const handleCallback: <T>(context: ReactZoomPanPinchRef, event: T, callback?: ((context: ReactZoomPanPinchRef, event: T) => void) | undefined) => void;
@@ -0,0 +1,2 @@
1
+ import { ReactZoomPanPinchContext, ReactZoomPanPinchRef } from "../models/context.model";
2
+ export declare const getContext: (contextInstance: ReactZoomPanPinchContext) => ReactZoomPanPinchRef;
@@ -0,0 +1 @@
1
+ export declare function makePassiveEventOption(): any;
@@ -0,0 +1,2 @@
1
+ export declare const isExcludedNode: (node: HTMLElement, excluded: string[]) => boolean;
2
+ export declare const cancelTimeout: (timeout: ReturnType<typeof setTimeout> | null) => void;
@@ -0,0 +1,7 @@
1
+ export * from "./calculations.utils";
2
+ export * from "./callback.utils";
3
+ export * from "./context.utils";
4
+ export * from "./event.utils";
5
+ export * from "./helpers.utils";
6
+ export * from "./state.utils";
7
+ export * from "./styles.utils";
@@ -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;
@@ -0,0 +1,3 @@
1
+ import { StateType } from "models";
2
+ export declare const getTransformStyles: (x: number, y: number, scale: number) => string;
3
+ export declare const getCenterPosition: (scale: number, wrapperComponent: HTMLDivElement, contentComponent: HTMLDivElement) => StateType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-zoom-pan-pinch",
3
- "version": "2.2.1",
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.13.14",
35
- "@babel/runtime": "^7.13.10",
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.3.5",
39
- "@storybook/addon-actions": "^6.3.5",
40
- "@storybook/addon-docs": "^6.3.5",
41
- "@storybook/addon-essentials": "^6.3.5",
42
- "@storybook/addon-links": "^6.3.5",
43
- "@storybook/addon-storysource": "^6.3.5",
44
- "@storybook/preset-create-react-app": "^3.2.0",
45
- "@storybook/react": "^6.3.5",
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": "^4.20.0",
52
- "@typescript-eslint/parser": "^4.20.0",
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": "^7.23.0",
58
- "eslint-config-airbnb": "18.2.1",
59
- "eslint-config-prettier": "^8.1.0",
60
- "eslint-plugin-flowtype": "^5.4.0",
61
- "eslint-plugin-import": "^2.22.1",
62
- "eslint-plugin-jsx-a11y": "^6.4.1",
63
- "eslint-plugin-prettier": "^3.3.1",
64
- "eslint-plugin-react": "^7.23.1",
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": "^4.0.3",
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": "^8.1.0",
80
+ "ts-loader": "^9.4.2",
77
81
  "typescript": "^4.2.3",
78
- "webpack-cli": "^4.6.0"
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-context";
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, useState } from "react";
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 { TransformContext } from "./transform-context";
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 [innerRef, setRef] = useState<ReactZoomPanPinchRef | null>(null);
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, () => innerRef as any, [innerRef]);
34
+ useImperativeHandle(ref, () => getContext(instance), [instance]);
13
35
 
14
- return <TransformContext {...props} setRef={setRef as any} />;
36
+ return <Context.Provider value={value}>{content}</Context.Provider>;
15
37
  },
16
38
  );
17
39
 
@@ -1,8 +1,6 @@
1
1
  import {
2
2
  LibrarySetup,
3
3
  ReactZoomPanPinchContext,
4
- } from "../models/context.model";
5
- import {
6
4
  ReactZoomPanPinchComponentHelpers,
7
5
  ReactZoomPanPinchState,
8
6
  } from "../models/context.model";
@@ -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 = function (t: number): number {
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 = function (t: number): number {
11
+ const linear = (t: number): number => {
10
12
  return t;
11
13
  };
12
14
  // accelerating from zero velocity
13
- const easeInQuad = function (t: number): number {
15
+ const easeInQuad = (t: number): number => {
14
16
  return t * t;
15
17
  };
16
18
  // decelerating to zero velocity
17
- const easeOutQuad = function (t: number): number {
19
+ const easeOutQuad = (t: number): number => {
18
20
  return t * (2 - t);
19
21
  };
20
22
  // acceleration until halfway, then deceleration
21
- const easeInOutQuad = function (t: number): number {
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 = function (t: number): number {
27
+ const easeInCubic = (t: number): number => {
26
28
  return t * t * t;
27
29
  };
28
30
  // decelerating to zero velocity
29
- const easeOutCubic = function (t: number): number {
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 = function (t: number): number {
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 = function (t: number): number {
39
+ const easeInQuart = (t: number): number => {
38
40
  return t * t * t * t;
39
41
  };
40
42
  // decelerating to zero velocity
41
- const easeOutQuart = function (t: number): number {
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 = function (t: number): number {
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 = function (t: number): number {
51
+ const easeInQuint = (t: number): number => {
50
52
  return t * t * t * t * t;
51
53
  };
52
54
  // decelerating to zero velocity