react-zoom-pan-pinch 2.1.2 → 2.2.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 (73) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +43 -0
  3. package/dist/index.cjs.js +87 -60
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.d.ts +11 -2
  6. package/dist/index.esm.js +87 -60
  7. package/dist/index.esm.js.map +1 -1
  8. package/package.json +13 -12
  9. package/src/.eslintrc.js +36 -0
  10. package/src/components/transform-component.module.css +30 -0
  11. package/src/components/transform-component.tsx +52 -0
  12. package/src/components/transform-context.tsx +493 -0
  13. package/src/components/transform-wrapper.tsx +18 -0
  14. package/src/constants/state.constants.ts +88 -0
  15. package/src/core/animations/animations.constants.ts +76 -0
  16. package/src/core/animations/animations.utils.ts +109 -0
  17. package/src/core/bounds/bounds.types.ts +8 -0
  18. package/src/core/bounds/bounds.utils.ts +157 -0
  19. package/src/core/double-click/double-click.logic.ts +75 -0
  20. package/src/core/handlers/handlers.logic.ts +112 -0
  21. package/src/core/handlers/handlers.utils.ts +202 -0
  22. package/src/core/pan/panning.logic.ts +99 -0
  23. package/src/core/pan/panning.utils.ts +199 -0
  24. package/src/core/pan/velocity.logic.ts +148 -0
  25. package/src/core/pan/velocity.utils.ts +79 -0
  26. package/src/core/pinch/pinch.logic.ts +83 -0
  27. package/src/core/pinch/pinch.utils.ts +88 -0
  28. package/src/core/wheel/wheel.logic.ts +118 -0
  29. package/src/core/wheel/wheel.utils.ts +121 -0
  30. package/src/core/zoom/zoom.logic.ts +69 -0
  31. package/src/core/zoom/zoom.utils.ts +58 -0
  32. package/src/hooks/use-transform-context.tsx +16 -0
  33. package/src/index.ts +6 -0
  34. package/src/models/calculations.model.ts +26 -0
  35. package/src/models/context.model.ts +179 -0
  36. package/src/models/helpers.model.ts +15 -0
  37. package/src/models/index.ts +3 -0
  38. package/src/react-app-env.d.ts +1 -0
  39. package/src/stories/assets/big-image.jpeg +0 -0
  40. package/src/stories/assets/medium-image.jpg +0 -0
  41. package/src/stories/assets/small-image.jpg +0 -0
  42. package/src/stories/assets/svg-example.svg +14 -0
  43. package/src/stories/docs/Introduction.stories.mdx +97 -0
  44. package/src/stories/docs/handlers.stories.mdx +48 -0
  45. package/src/stories/docs/handlers.tsx +107 -0
  46. package/src/stories/docs/props.stories.mdx +92 -0
  47. package/src/stories/docs/props.tsx +490 -0
  48. package/src/stories/examples/content/content.stories.mdx +122 -0
  49. package/src/stories/examples/content-rerendering/content-updating.stories.mdx +42 -0
  50. package/src/stories/examples/content-rerendering/example.tsx +74 -0
  51. package/src/stories/examples/controls/controls.stories.mdx +71 -0
  52. package/src/stories/examples/image-big/image-big.stories.mdx +44 -0
  53. package/src/stories/examples/image-medium/image-medium.stories.mdx +42 -0
  54. package/src/stories/examples/image-small/image-small.stories.mdx +42 -0
  55. package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +47 -0
  56. package/src/stories/examples/zoom-to-element/example.tsx +91 -0
  57. package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +28 -0
  58. package/src/stories/types/args.types.ts +201 -0
  59. package/src/stories/utils/args.utils.ts +34 -0
  60. package/src/stories/utils/code.utils.tsx +21 -0
  61. package/src/stories/utils/controls.utils.tsx +26 -0
  62. package/src/stories/utils/index.ts +3 -0
  63. package/src/stories/utils/styles.module.css +29 -0
  64. package/src/styles.css +8 -0
  65. package/src/typings.d.ts +10 -0
  66. package/src/utils/calculations.utils.ts +16 -0
  67. package/src/utils/callback.utils.ts +11 -0
  68. package/src/utils/context.utils.ts +27 -0
  69. package/src/utils/event.utils.ts +22 -0
  70. package/src/utils/helpers.utils.ts +27 -0
  71. package/src/utils/index.ts +7 -0
  72. package/src/utils/state.utils.ts +40 -0
  73. package/src/utils/styles.utils.ts +27 -0
@@ -0,0 +1,490 @@
1
+ import React from "react";
2
+
3
+ import { ReactZoomPanPinchProps } from "models";
4
+ import { initialSetup, initialState } from "../../constants/state.constants";
5
+ import { animations } from "../../core/animations/animations.constants";
6
+
7
+ export type ControlsOptionsType = {
8
+ name: React.ReactNode;
9
+ type: string[];
10
+ defaultValue: string;
11
+ description: string;
12
+ isObjectRow?: boolean;
13
+ };
14
+
15
+ export type ComponentProps = Record<
16
+ keyof Omit<ReactZoomPanPinchProps, "children">,
17
+ | Omit<ControlsOptionsType, "name" | "isObjectRow">
18
+ | Record<string, Omit<ControlsOptionsType, "name" | "isObjectRow">>
19
+ >;
20
+
21
+ const getPropsTable = (propsTable: any): ControlsOptionsType[] => {
22
+ return Object.keys(propsTable).reduce<ControlsOptionsType[]>((acc, key) => {
23
+ if (Array.isArray(propsTable[key]?.type)) {
24
+ acc.push({
25
+ ...propsTable[key],
26
+ name: key,
27
+ });
28
+ } else {
29
+ Object.keys(propsTable[key]).forEach((prop) => {
30
+ acc.push({
31
+ ...propsTable[key][prop],
32
+ isObjectRow: key === prop,
33
+ name:
34
+ key === prop ? (
35
+ <b>{prop}</b>
36
+ ) : (
37
+ <>
38
+ {key}.<b>{prop}</b>
39
+ </>
40
+ ),
41
+ });
42
+ });
43
+ }
44
+ return acc;
45
+ }, []);
46
+ };
47
+
48
+ export const componentPropsTable: Record<
49
+ string,
50
+ Omit<ControlsOptionsType, "name">
51
+ > = {
52
+ wrapperClass: {
53
+ type: ["string"],
54
+ defaultValue: "''",
55
+ description: "Wrapper element class",
56
+ },
57
+ contentClass: {
58
+ type: ["string"],
59
+ defaultValue: "''",
60
+ description: "Content element class",
61
+ },
62
+ wrapperStyle: {
63
+ type: ["ReactCSSProperties"],
64
+ defaultValue: "undefined",
65
+ description: "Wrapper element style object",
66
+ },
67
+ contentStyle: {
68
+ type: ["ReactCSSProperties"],
69
+ defaultValue: "undefined",
70
+ description: "Content element style object",
71
+ },
72
+ };
73
+
74
+ export const wrapperPropsTable: ComponentProps = {
75
+ ref: {
76
+ type: ["React.Ref<ReactZoomPanPinchRef>"],
77
+ defaultValue: "undefined",
78
+ description: "Get ref value of the react-zoom-pan-pinch context",
79
+ },
80
+ initialScale: {
81
+ type: ["number"],
82
+ defaultValue: String(initialState.scale),
83
+ description:
84
+ "Scale used only as initial value. It will be also used when triggering resetTransform() method or double click feature with 'reset' mode.",
85
+ },
86
+ initialPositionX: {
87
+ type: ["number"],
88
+ defaultValue: String(initialState.positionX),
89
+ description:
90
+ "Position X used only as initial value. It will be also used when triggering resetTransform() method or double click feature with 'reset' mode. Value should be provided in px.",
91
+ },
92
+ initialPositionY: {
93
+ type: ["number"],
94
+ defaultValue: String(initialState.positionY),
95
+ description:
96
+ "Position Y used only as initial value. It will be also used when triggering resetTransform() method or double click feature with 'reset' mode. Value should be provided in px.",
97
+ },
98
+ disabled: {
99
+ type: ["boolean"],
100
+ defaultValue: String(initialSetup.disabled),
101
+ description:
102
+ "This is 'global' disable props. Setting it as a 'true' value blocks all functionalities of library. For disabling parts of it like panning, zooming, pinch - checkout the dedicated sections below.",
103
+ },
104
+ minPositionX: {
105
+ type: ["number"],
106
+ defaultValue: String(initialSetup.minPositionX),
107
+ description:
108
+ "Bounding position which will limit the transformation to given value. Value should be provided in px.",
109
+ },
110
+ maxPositionX: {
111
+ type: ["number"],
112
+ defaultValue: String(initialSetup.maxPositionX),
113
+ description:
114
+ "Bounding position which will limit the transformation to given value. Value should be provided in px.",
115
+ },
116
+ minPositionY: {
117
+ type: ["number"],
118
+ defaultValue: String(initialSetup.minPositionY),
119
+ description:
120
+ "Bounding position which will limit the transformation to given value. Value should be provided in px.",
121
+ },
122
+ maxPositionY: {
123
+ type: ["number"],
124
+ defaultValue: String(initialSetup.minPositionY),
125
+ description:
126
+ "Bounding position which will limit the transformation to given value. Value should be provided in px.",
127
+ },
128
+ minScale: {
129
+ type: ["number"],
130
+ defaultValue: String(initialSetup.minScale),
131
+ description: "Bounding position which will limit the scale to given value",
132
+ },
133
+ maxScale: {
134
+ type: ["number"],
135
+ defaultValue: String(initialSetup.maxScale),
136
+ description: "Bounding position which will limit the scale to given value",
137
+ },
138
+ limitToBounds: {
139
+ type: ["boolean"],
140
+ defaultValue: String(initialSetup.limitToBounds),
141
+ description:
142
+ "Prop used to block panning/zooming outside of the scaled element, so the library will always keep it inside the wrapper view.",
143
+ },
144
+ centerZoomedOut: {
145
+ type: ["boolean"],
146
+ defaultValue: String(initialSetup.centerZoomedOut),
147
+ description:
148
+ "When the zoom goes under the 1 value, the library will keep the content component always in the center. Setting it to false will allow to move the scaled element.",
149
+ },
150
+ centerOnInit: {
151
+ type: ["boolean"],
152
+ defaultValue: String(initialSetup.centerOnInit),
153
+ description:
154
+ "When the prop is set to truth the content component will get centered based on the size of it's wrapper.",
155
+ },
156
+ disablePadding: {
157
+ type: ["boolean"],
158
+ defaultValue: String(initialSetup.disablePadding),
159
+ description:
160
+ "Used to disable panning, zooming boundary padding effect. By enabling this option, you will not be able to zoom outside the image area.",
161
+ },
162
+ wheel: {
163
+ wheel: {
164
+ type: [""],
165
+ defaultValue: "",
166
+ description: "",
167
+ },
168
+ step: {
169
+ type: ["number"],
170
+ defaultValue: String(initialSetup.wheel.step),
171
+ description: "The sensitivity of zooming with the wheel/touchpad.",
172
+ },
173
+ disabled: {
174
+ type: ["boolean"],
175
+ defaultValue: String(initialSetup.wheel.disabled),
176
+ description:
177
+ "Disable the mouse wheel and touchpad zooming functionalities, it will NOT affect pinching.",
178
+ },
179
+ wheelDisabled: {
180
+ type: ["boolean"],
181
+ defaultValue: String(initialSetup.wheel.wheelDisabled),
182
+ description:
183
+ "Disable only mouse wheel zooming functionality, it will NOT affect pinching and touchpad.",
184
+ },
185
+ touchPadDisabled: {
186
+ type: ["boolean"],
187
+ defaultValue: String(initialSetup.wheel.touchPadDisabled),
188
+ description:
189
+ "Disable only touchpad zooming functionality, it will NOT affect pinching and mouse wheel.",
190
+ },
191
+ activationKeys: {
192
+ type: ["string[]"],
193
+ defaultValue: String(initialSetup.wheel.activationKeys),
194
+ description:
195
+ "List of keys which, when held down, should activate this feature.",
196
+ },
197
+ excluded: {
198
+ type: ["string[]"],
199
+ defaultValue: String(initialSetup.wheel.excluded),
200
+ description:
201
+ "List of the class names or tags that should not activate this feature. (E.g. ['my-custom-class-name', 'div', 'a'])",
202
+ },
203
+ },
204
+ panning: {
205
+ panning: {
206
+ type: [""],
207
+ defaultValue: "",
208
+ description: "",
209
+ },
210
+ disabled: {
211
+ type: ["boolean"],
212
+ defaultValue: String(initialSetup.panning.disabled),
213
+ description: "Disable the panning feature.",
214
+ },
215
+ velocityDisabled: {
216
+ type: ["boolean"],
217
+ defaultValue: String(initialSetup.panning.velocityDisabled),
218
+ description:
219
+ "Disable the panning velocity feature. It's triggered when you release the mouse button so the content is still moving after it and slowing down with calculated time.",
220
+ },
221
+ lockAxisX: {
222
+ type: ["string[]"],
223
+ defaultValue: String(initialSetup.panning.activationKeys),
224
+ description:
225
+ "List of keys which, when held down, should activate this feature.",
226
+ },
227
+ lockAxisY: {
228
+ type: ["string[]"],
229
+ defaultValue: String(initialSetup.panning.activationKeys),
230
+ description:
231
+ "List of keys which, when held down, should activate this feature.",
232
+ },
233
+ activationKeys: {
234
+ type: ["string[]"],
235
+ defaultValue: String(initialSetup.panning.activationKeys),
236
+ description:
237
+ "List of keys which, when held down, should activate this feature.",
238
+ },
239
+ excluded: {
240
+ type: ["string[]"],
241
+ defaultValue: String(initialSetup.panning.excluded),
242
+ description:
243
+ "List of the class names or tags that should not activate this feature. (E.g. ['my-custom-class-name', 'div', 'a'])",
244
+ },
245
+ },
246
+ pinch: {
247
+ pinch: {
248
+ type: [""],
249
+ defaultValue: "",
250
+ description: "",
251
+ },
252
+ step: {
253
+ type: ["number"],
254
+ defaultValue: String(initialSetup.pinch.step),
255
+ description: "The sensitivity of zooming with the wheel/touchpad.",
256
+ },
257
+ disabled: {
258
+ type: ["boolean"],
259
+ defaultValue: String(initialSetup.pinch.disabled),
260
+ description:
261
+ "Disable the pinching zoom functionality, it will NOT affect mouse wheel/touchpad zooming.",
262
+ },
263
+ excluded: {
264
+ type: ["string[]"],
265
+ defaultValue: String(initialSetup.pinch.excluded),
266
+ description:
267
+ "List of the class names or tags that should not activate this feature. (E.g. ['my-custom-class-name', 'div', 'a'])",
268
+ },
269
+ },
270
+ doubleClick: {
271
+ doubleClick: {
272
+ type: [""],
273
+ defaultValue: "",
274
+ description: "",
275
+ },
276
+ disabled: {
277
+ type: ["boolean"],
278
+ defaultValue: String(initialSetup.doubleClick.disabled),
279
+ description: "Disable the double click feature.",
280
+ },
281
+ step: {
282
+ type: ["number"],
283
+ defaultValue: String(initialSetup.doubleClick.step),
284
+ description:
285
+ "The sensitivity of zooming in or out when the double click mode is set to 'zoomIn' or 'zoomOut'.",
286
+ },
287
+ mode: {
288
+ type: ["zoomIn", "zoomOut", "reset"],
289
+ defaultValue: String(initialSetup.doubleClick.mode),
290
+ description:
291
+ "The mode of the double click feature. Zoom in/Zoom out will change the scale with the given step settings. The reset functionality will take change transform to the initial values.",
292
+ },
293
+ animationTime: {
294
+ type: ["number"],
295
+ defaultValue: String(initialSetup.doubleClick.animationTime),
296
+ description: "Time of the triggered double click animation.",
297
+ },
298
+ animationType: {
299
+ type: Object.keys(animations),
300
+ defaultValue: String(initialSetup.doubleClick.animationType),
301
+ description: "Animations types to choose from.",
302
+ },
303
+ excluded: {
304
+ type: ["string[]"],
305
+ defaultValue: String(initialSetup.doubleClick.excluded),
306
+ description:
307
+ "List of the class names or tags that should not activate this feature. (E.g. ['my-custom-class-name', 'div', 'a'])",
308
+ },
309
+ },
310
+ zoomAnimation: {
311
+ zoomAnimation: {
312
+ type: [""],
313
+ defaultValue: "",
314
+ description: "",
315
+ },
316
+ disabled: {
317
+ type: ["boolean"],
318
+ defaultValue: String(initialSetup.zoomAnimation.disabled),
319
+ description: "Disable the double click feature.",
320
+ },
321
+ size: {
322
+ type: ["number"],
323
+ defaultValue: String(initialSetup.zoomAnimation.disabled),
324
+ description:
325
+ "Thanks to size, we can control the zoom out values larger than that controlled by the value of another 'minScale' prop. This results in an animated return of the value to the minimum scale when the zooming has finished. This works for both touchpad zooming and pinching.",
326
+ },
327
+ animationTime: {
328
+ type: ["number"],
329
+ defaultValue: String(initialSetup.zoomAnimation.animationTime),
330
+ description: "Time of the triggered double click animation.",
331
+ },
332
+ animationType: {
333
+ type: Object.keys(animations),
334
+ defaultValue: String(initialSetup.zoomAnimation.animationType),
335
+ description: "Animations types to choose from.",
336
+ },
337
+ },
338
+ alignmentAnimation: {
339
+ alignmentAnimation: {
340
+ type: [""],
341
+ defaultValue: "",
342
+ description: "",
343
+ },
344
+ disabled: {
345
+ type: ["boolean"],
346
+ defaultValue: String(initialSetup.alignmentAnimation.disabled),
347
+ description: "Disable the double click feature.",
348
+ },
349
+ sizeX: {
350
+ type: ["number"],
351
+ defaultValue: String(initialSetup.alignmentAnimation.sizeX),
352
+ description:
353
+ "Thanks to size, we can control the movement of our content component beyond the calculated limits. This results in an animation of a fallback to the closest accepted limits, however, this is only possible when the other 'limitToBounds' prop is set to true.",
354
+ },
355
+ sizeY: {
356
+ type: ["number"],
357
+ defaultValue: String(initialSetup.alignmentAnimation.sizeY),
358
+ description:
359
+ "Thanks to size, we can control the movement of our content component beyond the calculated limits. This results in an animation of a fallback to the closest accepted limits, however, this is only possible when the other 'limitToBounds' prop is set to true.",
360
+ },
361
+ velocityAlignmentTime: {
362
+ type: ["number"],
363
+ defaultValue: String(initialSetup.alignmentAnimation.animationTime),
364
+ description:
365
+ "Time of the velocity alignment animation. It is fired when acceleration begins when we are outside the wrapper limits (in the area defined by the above prop size)",
366
+ },
367
+ animationTime: {
368
+ type: ["number"],
369
+ defaultValue: String(initialSetup.alignmentAnimation.animationTime),
370
+ description: "Time of the alignment animation.",
371
+ },
372
+ animationType: {
373
+ type: Object.keys(animations),
374
+ defaultValue: String(initialSetup.alignmentAnimation.animationType),
375
+ description: "Animations types to choose from.",
376
+ },
377
+ },
378
+ velocityAnimation: {
379
+ velocityAnimation: {
380
+ type: [""],
381
+ defaultValue: "",
382
+ description: "",
383
+ },
384
+ disabled: {
385
+ type: ["boolean"],
386
+ defaultValue: String(initialSetup.velocityAnimation.disabled),
387
+ description: "Disable the double click feature.",
388
+ },
389
+ sensitivity: {
390
+ type: ["number"],
391
+ defaultValue: String(initialSetup.velocityAnimation.animationTime),
392
+ description:
393
+ "Additional variable that allows you to control the sensitivity of panning velocity",
394
+ },
395
+ animationTime: {
396
+ type: ["number"],
397
+ defaultValue: String(initialSetup.velocityAnimation.animationTime),
398
+ description: "Time of the triggered double click animation.",
399
+ },
400
+ animationType: {
401
+ type: Object.keys(animations),
402
+ defaultValue: String(initialSetup.velocityAnimation.animationType),
403
+ description: "Animations types to choose from.",
404
+ },
405
+ equalToMove: {
406
+ type: ["boolean"],
407
+ defaultValue: String(initialSetup.velocityAnimation.equalToMove),
408
+ description:
409
+ "The calculation of the velocity animation duration is adjusted to the length of the mouse movement",
410
+ },
411
+ },
412
+ onWheelStart: {
413
+ type: ["(ref: ReactZoomPanPinchRef, event) => void"],
414
+ defaultValue: "undefined",
415
+ description: "Callback fired when wheel/touchpad events are started",
416
+ },
417
+ onWheel: {
418
+ type: ["(ref: ReactZoomPanPinchRef, event) => void"],
419
+ defaultValue: "undefined",
420
+ description: "Callback fired when wheel/touchpad events are ongoing",
421
+ },
422
+ onWheelStop: {
423
+ type: ["(ref: ReactZoomPanPinchRef, event) => void"],
424
+ defaultValue: "undefined",
425
+ description: "Callback fired when wheel/touchpad events are finished",
426
+ },
427
+ onPanningStart: {
428
+ type: ["(ref: ReactZoomPanPinchRef, event) => void"],
429
+ defaultValue: "undefined",
430
+ description: "Callback fired when panning event has started",
431
+ },
432
+ onPanning: {
433
+ type: ["(ref: ReactZoomPanPinchRef, event) => void"],
434
+ defaultValue: "undefined",
435
+ description: "Callback fired when panning event is ongoing",
436
+ },
437
+ onPanningStop: {
438
+ type: ["(ref: ReactZoomPanPinchRef, event) => void"],
439
+ defaultValue: "undefined",
440
+ description: "Callback fired when panning event has finished",
441
+ },
442
+ onPinchingStart: {
443
+ type: ["(ref: ReactZoomPanPinchRef, event) => void"],
444
+ defaultValue: "undefined",
445
+ description: "Callback fired when pinch event has started",
446
+ },
447
+ onPinching: {
448
+ type: ["(ref: ReactZoomPanPinchRef, event) => void"],
449
+ defaultValue: "undefined",
450
+ description: "Callback fired when pinch event is ongoing",
451
+ },
452
+ onPinchingStop: {
453
+ type: ["(ref: ReactZoomPanPinchRef, event) => void"],
454
+ defaultValue: "undefined",
455
+ description: "Callback fired when pinch event has finished",
456
+ },
457
+ onZoomStart: {
458
+ type: ["(ref: ReactZoomPanPinchRef, event) => void"],
459
+ defaultValue: "undefined",
460
+ description:
461
+ "Callback fired when any of zoom events are started (wheel/touchpad/pinch)",
462
+ },
463
+ onZoom: {
464
+ type: ["(ref: ReactZoomPanPinchRef, event) => void"],
465
+ defaultValue: "undefined",
466
+ description:
467
+ "Callback fired when any of zoom events are ongoing (wheel/touchpad/pinch)",
468
+ },
469
+ onZoomStop: {
470
+ type: ["(ref: ReactZoomPanPinchRef, event) => void"],
471
+ defaultValue: "undefined",
472
+ description:
473
+ "Callback fired when any of zoom events are finished (wheel/touchpad/pinch)",
474
+ },
475
+ onTransformed: {
476
+ type: [
477
+ "(ref: ReactZoomPanPinchRef, scale: number, positionX: number, positionY: number ) => void",
478
+ ],
479
+ defaultValue: "undefined",
480
+ description: "Callback fired when on each transform",
481
+ },
482
+ onInit: {
483
+ type: ["(ref: ReactZoomPanPinchRef) => void"],
484
+ defaultValue: "undefined",
485
+ description: "Callback fired when components get mounted",
486
+ },
487
+ };
488
+
489
+ export const componentProps = getPropsTable(componentPropsTable);
490
+ export const wrapperProps = getPropsTable(wrapperPropsTable);
@@ -0,0 +1,122 @@
1
+ import { Meta, Story, ArgsTable, Canvas } from "@storybook/addon-docs/blocks";
2
+ import { action } from "@storybook/addon-actions";
3
+
4
+ import { TransformWrapper } from "../../../components/transform-wrapper";
5
+ import { TransformComponent } from "../../../components/transform-component";
6
+ import { argsTypes } from "../../types/args.types.ts";
7
+ import { normalizeArgs } from "../../utils";
8
+
9
+ import exampleImg from "../../assets/small-image.jpg";
10
+
11
+ export const Template = (args) => (
12
+ <TransformWrapper {...normalizeArgs(args)}>
13
+ <TransformComponent
14
+ wrapperStyle={{ maxWidth: "100%", maxHeight: "calc(100vh - 50px)" }}
15
+ >
16
+ <div style={{ background: "#444", color: "white", padding: "50px" }}>
17
+ <h1>No scrollbars needed</h1>
18
+ <h2>Use mouse or gestures to move around</h2>
19
+ <button
20
+ onClick={() => alert("You can still interact with click events!")}
21
+ >
22
+ Click me!
23
+ </button>
24
+ <div
25
+ style={{
26
+ display: "flex",
27
+ overflow: "auto",
28
+ maxWidth: "100%",
29
+ padding: "10px",
30
+ }}
31
+ >
32
+ <div
33
+ style={{
34
+ width: "100px",
35
+ height: "100px",
36
+ padding: "10px",
37
+ background: "red",
38
+ }}
39
+ className="panningDisabled"
40
+ >
41
+ Panning is DISABLED on this element
42
+ </div>
43
+ <div
44
+ style={{
45
+ width: "100px",
46
+ height: "100px",
47
+ padding: "10px",
48
+ background: "blue",
49
+ }}
50
+ className="wheelDisabled"
51
+ >
52
+ Wheel is DISABLED on this element
53
+ </div>
54
+ <div
55
+ style={{
56
+ width: "100px",
57
+ height: "100px",
58
+ padding: "10px",
59
+ background: "green",
60
+ }}
61
+ className="pinchDisabled"
62
+ >
63
+ Pinch is DISABLED on this element
64
+ </div>
65
+ </div>
66
+ <p>
67
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
68
+ eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
69
+ minim veniam, quis nostrud exercitation ullamco laboris nisi ut
70
+ aliquip ex ea commodo consequat. Duis aute irure dolor in
71
+ reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
72
+ pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
73
+ culpa qui officia deserunt mollit anim id est laborum
74
+ </p>
75
+ <img src={exampleImg} alt="" />
76
+ <p>
77
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
78
+ eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
79
+ minim veniam, quis nostrud exercitation ullamco laboris nisi ut
80
+ aliquip ex ea commodo consequat. Duis aute irure dolor in
81
+ reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
82
+ pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
83
+ culpa qui officia deserunt mollit anim id est laborum
84
+ </p>
85
+ </div>
86
+ </TransformComponent>
87
+ </TransformWrapper>
88
+ );
89
+
90
+ <Meta
91
+ title="Examples/Mixed Content"
92
+ component={TransformWrapper}
93
+ argTypes={{
94
+ ...argsTypes,
95
+ "wheel.excluded": {
96
+ ...argsTypes["wheel.excluded"],
97
+ defaultValue: ["wheelDisabled"],
98
+ },
99
+ "panning.excluded": {
100
+ ...argsTypes["panning.excluded"],
101
+ defaultValue: ["panningDisabled"],
102
+ },
103
+ "pinch.excluded": {
104
+ ...argsTypes["pinch.excluded"],
105
+ defaultValue: ["pinchDisabled"],
106
+ },
107
+ }}
108
+ />
109
+
110
+ # Mixed Content
111
+
112
+ <br />
113
+
114
+ ### Preview:
115
+
116
+ <Canvas>
117
+ <Story name="Mixed Content">{(args) => <Template {...args} />}</Story>
118
+ </Canvas>
119
+
120
+ ## Component API
121
+
122
+ <ArgsTable story="Mixed Content" />
@@ -0,0 +1,42 @@
1
+ import { Meta, Story, ArgsTable, Canvas } from "@storybook/addon-docs/blocks";
2
+ import { action } from "@storybook/addon-actions";
3
+
4
+ import { TransformWrapper } from "../../../components/transform-wrapper";
5
+ import { argsTypes } from "../../types/args.types";
6
+ import { Example } from "./example";
7
+
8
+ export const Template = (args) => <Example {...args} />;
9
+
10
+ <Meta
11
+ title="Examples/Rerendering content"
12
+ component={TransformWrapper}
13
+ argTypes={{
14
+ ...argsTypes,
15
+ "wheel.excluded": {
16
+ ...argsTypes["wheel.excluded"],
17
+ defaultValue: ["wheelDisabled"],
18
+ },
19
+ "panning.excluded": {
20
+ ...argsTypes["panning.excluded"],
21
+ defaultValue: ["panningDisabled"],
22
+ },
23
+ "pinch.excluded": {
24
+ ...argsTypes["pinch.excluded"],
25
+ defaultValue: ["pinchDisabled"],
26
+ },
27
+ }}
28
+ />
29
+
30
+ # Rerendering content
31
+
32
+ <br />
33
+
34
+ ### Preview:
35
+
36
+ <Canvas>
37
+ <Story name="Rerendering content">{(args) => <Template {...args} />}</Story>
38
+ </Canvas>
39
+
40
+ ## Component API
41
+
42
+ <ArgsTable story="Rerendering content" />