react-zoom-pan-pinch 3.7.0 → 4.0.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 (139) hide show
  1. package/dist/index.cjs.js +785 -310
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +117 -23
  4. package/dist/index.esm.js +781 -302
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +73 -62
  7. package/src/components/index.ts +5 -0
  8. package/src/components/keep-scale/keep-scale.tsx +28 -0
  9. package/src/components/mini-map/mini-map.tsx +292 -0
  10. package/src/components/mini-map/use-resize.hook.ts +74 -0
  11. package/src/components/transform-component/transform-component.module.css +43 -0
  12. package/src/components/transform-component/transform-component.tsx +96 -0
  13. package/src/components/transform-wrapper/transform-wrapper.tsx +39 -0
  14. package/src/components/virtualize/virtualize.tsx +133 -0
  15. package/src/components/virtualize/virtualize.utils.ts +104 -0
  16. package/src/constants/state.constants.ts +99 -0
  17. package/src/core/animations/animations.constants.ts +78 -0
  18. package/src/core/animations/animations.utils.ts +115 -0
  19. package/src/core/bounds/bounds.types.ts +8 -0
  20. package/src/core/bounds/bounds.utils.ts +226 -0
  21. package/src/core/double-click/double-click.logic.ts +127 -0
  22. package/src/core/handlers/handlers.logic.ts +122 -0
  23. package/src/core/handlers/handlers.utils.ts +243 -0
  24. package/src/core/instance.core.ts +704 -0
  25. package/src/core/pan/panning.logic.ts +122 -0
  26. package/src/core/pan/panning.utils.ts +216 -0
  27. package/src/core/pan/velocity.logic.ts +187 -0
  28. package/src/core/pan/velocity.utils.ts +83 -0
  29. package/src/core/pinch/pinch.logic.ts +139 -0
  30. package/src/core/pinch/pinch.utils.ts +95 -0
  31. package/src/core/wheel/wheel.logic.ts +161 -0
  32. package/src/core/wheel/wheel.utils.ts +157 -0
  33. package/src/core/zoom/zoom.logic.ts +71 -0
  34. package/src/core/zoom/zoom.utils.ts +62 -0
  35. package/src/hooks/index.ts +5 -0
  36. package/src/hooks/use-controls.tsx +9 -0
  37. package/src/hooks/use-transform-component.tsx +30 -0
  38. package/src/hooks/use-transform-context.tsx +13 -0
  39. package/src/hooks/use-transform-effect.tsx +22 -0
  40. package/src/hooks/use-transform-init.tsx +28 -0
  41. package/src/hooks/use-zoom-pan-pinch.tsx +48 -0
  42. package/src/index.ts +6 -0
  43. package/src/models/calculations.model.ts +34 -0
  44. package/src/models/context.model.ts +218 -0
  45. package/src/models/helpers.model.ts +15 -0
  46. package/src/models/index.ts +3 -0
  47. package/src/react-app-env.d.ts +1 -0
  48. package/src/stories/assets/big-image.jpeg +0 -0
  49. package/src/stories/assets/map.jpg +0 -0
  50. package/src/stories/assets/medium-image.jpg +0 -0
  51. package/src/stories/assets/pin.svg +1 -0
  52. package/src/stories/assets/small-image.jpg +0 -0
  53. package/src/stories/assets/svg-example.svg +14 -0
  54. package/src/stories/docs/DocTable.tsx +59 -0
  55. package/src/stories/docs/HandlerCards.tsx +102 -0
  56. package/src/stories/docs/Introduction.stories.mdx +135 -0
  57. package/src/stories/docs/PropTable.tsx +116 -0
  58. package/src/stories/docs/docs.module.css +370 -0
  59. package/src/stories/docs/handlers.stories.mdx +7 -0
  60. package/src/stories/docs/handlers.tsx +111 -0
  61. package/src/stories/docs/props.stories.mdx +11 -0
  62. package/src/stories/docs/props.tsx +571 -0
  63. package/src/stories/examples/axis-lock/axis-lock.stories.mdx +35 -0
  64. package/src/stories/examples/axis-lock/example.tsx +114 -0
  65. package/src/stories/examples/bounds/bounds.data.tsx +191 -0
  66. package/src/stories/examples/bounds/bounds.stories.mdx +99 -0
  67. package/src/stories/examples/center-zoomed-out/center-zoomed-out.stories.mdx +206 -0
  68. package/src/stories/examples/cinema/cinema-data.tsx +578 -0
  69. package/src/stories/examples/cinema/cinema.stories.mdx +30 -0
  70. package/src/stories/examples/cinema/example.tsx +378 -0
  71. package/src/stories/examples/cinema/image.png +0 -0
  72. package/src/stories/examples/content/content.stories.mdx +172 -0
  73. package/src/stories/examples/content/mixed-content.data.tsx +624 -0
  74. package/src/stories/examples/content-rerendering/content-updating.stories.mdx +34 -0
  75. package/src/stories/examples/content-rerendering/example.tsx +631 -0
  76. package/src/stories/examples/controls/controls.stories.mdx +120 -0
  77. package/src/stories/examples/image/example.tsx +149 -0
  78. package/src/stories/examples/image/image.stories.mdx +46 -0
  79. package/src/stories/examples/image-annotations/example.tsx +1442 -0
  80. package/src/stories/examples/image-annotations/image-annotations.stories.mdx +39 -0
  81. package/src/stories/examples/image-responsive/example.tsx +152 -0
  82. package/src/stories/examples/image-responsive/image-responsive.stories.mdx +51 -0
  83. package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +107 -0
  84. package/src/stories/examples/initial-transform/example.tsx +233 -0
  85. package/src/stories/examples/initial-transform/initial-transform.stories.mdx +37 -0
  86. package/src/stories/examples/keep-scale/example.tsx +882 -0
  87. package/src/stories/examples/keep-scale/keep-scale.stories.mdx +30 -0
  88. package/src/stories/examples/keep-scale/map.stories.mdx +28 -0
  89. package/src/stories/examples/medical-viewer/chest-xray.tsx +246 -0
  90. package/src/stories/examples/medical-viewer/example.tsx +690 -0
  91. package/src/stories/examples/medical-viewer/medical-viewer.stories.mdx +49 -0
  92. package/src/stories/examples/mini-map/example.tsx +122 -0
  93. package/src/stories/examples/mini-map/mini-map.stories.mdx +26 -0
  94. package/src/stories/examples/miro/example.tsx +1573 -0
  95. package/src/stories/examples/miro/miro.stories.mdx +31 -0
  96. package/src/stories/examples/padding/example.tsx +147 -0
  97. package/src/stories/examples/padding/padding.stories.mdx +35 -0
  98. package/src/stories/examples/product-card/example.tsx +594 -0
  99. package/src/stories/examples/product-card/product-card.stories.mdx +29 -0
  100. package/src/stories/examples/stadium/example.tsx +1040 -0
  101. package/src/stories/examples/stadium/stadium-data.ts +224 -0
  102. package/src/stories/examples/stadium/stadium.stories.mdx +32 -0
  103. package/src/stories/examples/stress/example.tsx +59 -0
  104. package/src/stories/examples/stress/stress-test.stories.mdx +28 -0
  105. package/src/stories/examples/svg-zoom-to-element/creativity.svg +143 -0
  106. package/src/stories/examples/svg-zoom-to-element/example.tsx +95 -0
  107. package/src/stories/examples/svg-zoom-to-element/svg-zoom-to-element.stories.mdx +28 -0
  108. package/src/stories/examples/text-selection/example.tsx +221 -0
  109. package/src/stories/examples/text-selection/text-selection.stories.mdx +31 -0
  110. package/src/stories/examples/velocity/example.tsx +908 -0
  111. package/src/stories/examples/velocity/velocity.stories.mdx +35 -0
  112. package/src/stories/examples/virtualize/example.tsx +239 -0
  113. package/src/stories/examples/virtualize/virtualize.stories.mdx +84 -0
  114. package/src/stories/examples/zoom-to-element/example.tsx +219 -0
  115. package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +31 -0
  116. package/src/stories/hooks/use-controls.stories.mdx +86 -0
  117. package/src/stories/hooks/use-transform-component.stories.mdx +108 -0
  118. package/src/stories/hooks/use-transform-context.stories.mdx +92 -0
  119. package/src/stories/hooks/use-transform-effect.stories.mdx +114 -0
  120. package/src/stories/hooks/use-transform-init.stories.mdx +105 -0
  121. package/src/stories/types/args.types.ts +192 -0
  122. package/src/stories/utils/args.utils.ts +35 -0
  123. package/src/stories/utils/bounds-overlay.tsx +168 -0
  124. package/src/stories/utils/code.utils.tsx +22 -0
  125. package/src/stories/utils/controls.utils.tsx +347 -0
  126. package/src/stories/utils/index.ts +5 -0
  127. package/src/stories/utils/styles.module.css +223 -0
  128. package/src/stories/utils/viewer.styles.ts +34 -0
  129. package/src/styles.css +8 -0
  130. package/src/typings.d.ts +21 -0
  131. package/src/utils/calculations.utils.ts +16 -0
  132. package/src/utils/callback.utils.ts +11 -0
  133. package/src/utils/context.utils.ts +49 -0
  134. package/src/utils/event.utils.ts +38 -0
  135. package/src/utils/helpers.utils.ts +22 -0
  136. package/src/utils/index.ts +8 -0
  137. package/src/utils/ref.utils.ts +32 -0
  138. package/src/utils/state.utils.ts +77 -0
  139. package/src/utils/styles.utils.ts +49 -0
@@ -0,0 +1,108 @@
1
+ import { Meta } from "@storybook/blocks";
2
+
3
+ import { DocTable } from "../docs/DocTable.tsx";
4
+
5
+ <Meta title="Hooks/useTransformComponent" />
6
+
7
+ # useTransformComponent
8
+
9
+ Subscribe to every transform change and **return a value** — typically JSX —
10
+ that updates in real time. This hook is the primary way to build UI that
11
+ reflects the current zoom, pan, or scale state without manual event wiring.
12
+
13
+ ## Signature
14
+
15
+ ```ts
16
+ function useTransformComponent<T>(
17
+ callback: (state: ReactZoomPanPinchContextState) => T,
18
+ ): T
19
+ ```
20
+
21
+ **`state`** contains:
22
+
23
+ ```ts
24
+ {
25
+ state: {
26
+ previousScale: number;
27
+ scale: number;
28
+ positionX: number;
29
+ positionY: number;
30
+ };
31
+ instance: ReactZoomPanPinchContext;
32
+ }
33
+ ```
34
+
35
+ ## How It Works
36
+
37
+ Internally, `useTransformComponent` subscribes to the library's `onChange`
38
+ event and calls your callback on every transform update. The return value is
39
+ stored in React state (`useState`), so the consuming component re-renders
40
+ whenever the transform changes.
41
+
42
+ ## When to Use
43
+
44
+ - **Scale badges** — show the current zoom level (`state.scale`)
45
+ - **Coordinate displays** — show positionX / positionY
46
+ - **Conditional rendering** — show/hide elements based on zoom level
47
+ - Any UI element that should **visually update** on every transform tick
48
+
49
+ ## Examples
50
+
51
+ ### Scale Indicator
52
+
53
+ ```tsx
54
+ function ScaleBadge() {
55
+ return useTransformComponent(({ state }) => (
56
+ <div className="badge">{state.scale.toFixed(2)}x</div>
57
+ ));
58
+ }
59
+ ```
60
+
61
+ ### Zoom Percentage
62
+
63
+ ```tsx
64
+ function ZoomPercent() {
65
+ return useTransformComponent(({ state }) => (
66
+ <span>{Math.round(state.scale * 100)}%</span>
67
+ ));
68
+ }
69
+ ```
70
+
71
+ ### Coordinates
72
+
73
+ ```tsx
74
+ function Coords() {
75
+ return useTransformComponent(({ state }) => (
76
+ <div>
77
+ X: {state.positionX.toFixed(0)}, Y: {state.positionY.toFixed(0)}
78
+ </div>
79
+ ));
80
+ }
81
+ ```
82
+
83
+ ## Performance
84
+
85
+ The callback fires on **every** transform event — every mouse move during a
86
+ pan, every wheel tick, every pinch frame. Keep the callback lightweight.
87
+ Avoid expensive computations or large JSX trees inside it. If you only need
88
+ to run side-effects (not render UI), use `useTransformEffect` instead.
89
+
90
+ ## vs Other Hooks
91
+
92
+ <DocTable
93
+ columns={[
94
+ { header: "Hook", style: "name" },
95
+ { header: "Purpose", style: "type" },
96
+ { header: "Re-renders?", style: "text" },
97
+ ]}
98
+ rows={[
99
+ ["useTransformComponent", "Render UI from state", "Yes"],
100
+ ["useTransformEffect", "Side-effects on change", "No"],
101
+ ["useControls", "Trigger actions", "No"],
102
+ ["useTransformContext", "Raw instance access", "No"],
103
+ ]}
104
+ />
105
+
106
+ ## Requirements
107
+
108
+ Must be called inside a descendant of `TransformWrapper`.
@@ -0,0 +1,92 @@
1
+ import { Meta } from "@storybook/blocks";
2
+
3
+ import { DocTable } from "../docs/DocTable.tsx";
4
+
5
+ <Meta title="Hooks/useTransformContext" />
6
+
7
+ # useTransformContext
8
+
9
+ The **lowest-level** hook — returns the raw library context (the `ZoomPanPinch`
10
+ instance). All other hooks (`useControls`, `useTransformComponent`,
11
+ `useTransformEffect`, `useTransformInit`) are built on top of this one.
12
+
13
+ ## Signature
14
+
15
+ ```ts
16
+ function useTransformContext(): ReactZoomPanPinchContext
17
+ ```
18
+
19
+ ## Return Value
20
+
21
+ The returned context object provides:
22
+
23
+ <DocTable
24
+ columns={[
25
+ { header: "Property", style: "name" },
26
+ { header: "Type", style: "type" },
27
+ { header: "Description", style: "text" },
28
+ ]}
29
+ rows={[
30
+ ["state", "{ scale, positionX, positionY, previousScale }", "Current mutable transform state"],
31
+ ["setup", "object", "Resolved configuration (minScale, maxScale, etc.)"],
32
+ ["wrapperComponent", "HTMLDivElement | null", "The wrapper DOM element"],
33
+ ["contentComponent", "HTMLDivElement | null", "The content DOM element"],
34
+ ["onChange", "(callback) => unsubscribe", "Subscribe to transform changes"],
35
+ ["onInit", "(callback) => unsubscribe", "Subscribe to initialization"],
36
+ ]}
37
+ />
38
+
39
+ ## When to Use
40
+
41
+ - **Building custom hooks** on top of the library internals
42
+ - **Direct DOM access** to wrapper/content elements for measurements
43
+ - **Advanced integrations** that need the raw instance (e.g., syncing with
44
+ external renderers like Canvas or WebGL)
45
+
46
+ Most applications should use `useControls` (for actions) or
47
+ `useTransformComponent` (for reactive state) instead.
48
+
49
+ ## Example — Custom Scale Logger
50
+
51
+ ```tsx
52
+ import { useEffect } from "react";
53
+ import { useTransformContext } from "react-zoom-pan-pinch";
54
+
55
+ function useLogScale() {
56
+ const ctx = useTransformContext();
57
+
58
+ useEffect(() => {
59
+ const unsub = ctx.onChange((ref) => {
60
+ console.log("Scale:", ref.instance.state.scale);
61
+ });
62
+ return unsub;
63
+ }, [ctx]);
64
+ }
65
+ ```
66
+
67
+ ## Example — Wrapper Dimensions
68
+
69
+ ```tsx
70
+ function useWrapperSize() {
71
+ const ctx = useTransformContext();
72
+ const wrapper = ctx.wrapperComponent;
73
+
74
+ if (!wrapper) return { width: 0, height: 0 };
75
+ return {
76
+ width: wrapper.offsetWidth,
77
+ height: wrapper.offsetHeight,
78
+ };
79
+ }
80
+ ```
81
+
82
+ ## Error Handling
83
+
84
+ Throws if called outside of `TransformWrapper`:
85
+
86
+ ```
87
+ Error: Transform context must be placed inside TransformWrapper
88
+ ```
89
+
90
+ ## Requirements
91
+
92
+ Must be called inside a descendant of `TransformWrapper`.
@@ -0,0 +1,114 @@
1
+ import { Meta } from "@storybook/blocks";
2
+
3
+ import { DocTable } from "../docs/DocTable.tsx";
4
+
5
+ <Meta title="Hooks/useTransformEffect" />
6
+
7
+ # useTransformEffect
8
+
9
+ Run a **side-effect** on every transform change — without triggering React
10
+ re-renders. Think of it as `useEffect` for transform state: your callback
11
+ fires on every pan, zoom, or pinch event, and can optionally return a cleanup
12
+ function.
13
+
14
+ ## Signature
15
+
16
+ ```ts
17
+ function useTransformEffect(
18
+ callback: (state: ReactZoomPanPinchContextState) => void | (() => void),
19
+ ): void
20
+ ```
21
+
22
+ **`state`** contains:
23
+
24
+ ```ts
25
+ {
26
+ state: { previousScale, scale, positionX, positionY };
27
+ instance: ReactZoomPanPinchContext;
28
+ }
29
+ ```
30
+
31
+ The callback can return a **cleanup function** that runs before the next
32
+ invocation and on unmount — the same pattern as `useEffect`.
33
+
34
+ ## When to Use
35
+
36
+ - **Analytics** — log zoom events or viewport positions
37
+ - **URL sync** — update query parameters with the current viewport
38
+ - **External state** — push transform data to a store (Redux, Zustand, etc.)
39
+ - **DOM mutations** — update a canvas overlay or external tooltip positions
40
+ - **Debounced saves** — persist viewport state after interaction stops
41
+
42
+ For rendering UI that updates with transform state, use
43
+ `useTransformComponent` instead — it manages React state and re-renders for you.
44
+
45
+ ## Examples
46
+
47
+ ### Sync to URL
48
+
49
+ ```tsx
50
+ import { useTransformEffect } from "react-zoom-pan-pinch";
51
+
52
+ function ViewportSync() {
53
+ useTransformEffect(({ state }) => {
54
+ const params = new URLSearchParams(window.location.search);
55
+ params.set("x", String(Math.round(state.positionX)));
56
+ params.set("y", String(Math.round(state.positionY)));
57
+ params.set("s", state.scale.toFixed(2));
58
+ window.history.replaceState(null, "", `?${params}`);
59
+ });
60
+
61
+ return null;
62
+ }
63
+ ```
64
+
65
+ ### Analytics Logging
66
+
67
+ ```tsx
68
+ function ZoomAnalytics() {
69
+ useTransformEffect(({ state }) => {
70
+ if (state.scale !== state.previousScale) {
71
+ analytics.track("zoom_changed", { scale: state.scale });
72
+ }
73
+ });
74
+
75
+ return null;
76
+ }
77
+ ```
78
+
79
+ ### Cleanup Pattern
80
+
81
+ ```tsx
82
+ function Overlay() {
83
+ useTransformEffect(({ state }) => {
84
+ const overlay = document.getElementById("canvas-overlay");
85
+ overlay?.style.setProperty("--scale", String(state.scale));
86
+
87
+ return () => {
88
+ overlay?.style.removeProperty("--scale");
89
+ };
90
+ });
91
+
92
+ return null;
93
+ }
94
+ ```
95
+
96
+ ## Key Differences
97
+
98
+ <DocTable
99
+ columns={[
100
+ { header: "" },
101
+ { header: "useTransformEffect", style: "type" },
102
+ { header: "useTransformComponent", style: "text" },
103
+ ]}
104
+ rows={[
105
+ ["Purpose", "Side-effects", "Render UI"],
106
+ ["Returns", "void", "T (your callback's return)"],
107
+ ["Re-renders?", "No", "Yes"],
108
+ ["Use case", "Logging, syncing, DOM", "Badges, labels, indicators"],
109
+ ]}
110
+ />
111
+
112
+ ## Requirements
113
+
114
+ Must be called inside a descendant of `TransformWrapper`.
@@ -0,0 +1,105 @@
1
+ import { Meta } from "@storybook/blocks";
2
+
3
+ import { DocTable } from "../docs/DocTable.tsx";
4
+
5
+ <Meta title="Hooks/useTransformInit" />
6
+
7
+ # useTransformInit
8
+
9
+ Run a callback **once** when the `TransformWrapper` content and wrapper DOM
10
+ elements are ready. If the components are already mounted when the hook runs,
11
+ the callback fires immediately. Otherwise, it waits for the internal `onInit`
12
+ event.
13
+
14
+ ## Signature
15
+
16
+ ```ts
17
+ function useTransformInit(
18
+ callback: (state: ReactZoomPanPinchContextState) => void | (() => void),
19
+ ): void
20
+ ```
21
+
22
+ **`state`** contains:
23
+
24
+ ```ts
25
+ {
26
+ state: { previousScale, scale, positionX, positionY };
27
+ instance: ReactZoomPanPinchContext;
28
+ }
29
+ ```
30
+
31
+ The callback can return a **cleanup function** that runs on unmount.
32
+
33
+ ## When to Use
34
+
35
+ - **Initial measurements** — read wrapper/content dimensions after mount
36
+ - **One-time setup** — configure external systems that depend on viewport size
37
+ - **Initial state logging** — record the starting transform values
38
+
39
+ For reacting to **every** transform change, use `useTransformEffect` instead.
40
+ This hook fires only once.
41
+
42
+ ## Examples
43
+
44
+ ### Read Initial Dimensions
45
+
46
+ ```tsx
47
+ import { useTransformInit } from "react-zoom-pan-pinch";
48
+
49
+ function Setup() {
50
+ useTransformInit(({ instance }) => {
51
+ const wrapper = instance.wrapperComponent;
52
+ if (wrapper) {
53
+ console.log("Viewport:", wrapper.offsetWidth, "x", wrapper.offsetHeight);
54
+ }
55
+ });
56
+
57
+ return null;
58
+ }
59
+ ```
60
+
61
+ ### External System Setup
62
+
63
+ ```tsx
64
+ function CanvasSetup() {
65
+ useTransformInit(({ state, instance }) => {
66
+ const canvas = initExternalCanvas({
67
+ width: instance.wrapperComponent?.offsetWidth ?? 0,
68
+ height: instance.wrapperComponent?.offsetHeight ?? 0,
69
+ initialScale: state.scale,
70
+ });
71
+
72
+ return () => {
73
+ canvas.destroy();
74
+ };
75
+ });
76
+
77
+ return null;
78
+ }
79
+ ```
80
+
81
+ ## Key Differences
82
+
83
+ <DocTable
84
+ columns={[
85
+ { header: "" },
86
+ { header: "useTransformInit", style: "type" },
87
+ { header: "useTransformEffect", style: "text" },
88
+ ]}
89
+ rows={[
90
+ ["Fires", "Once (on mount)", "On every transform change"],
91
+ ["Purpose", "Setup / measurements", "Ongoing side-effects"],
92
+ ["Deps", "[] (captured once)", "[callback, context]"],
93
+ ]}
94
+ />
95
+
96
+ ## Caveat
97
+
98
+ The dependency array is **empty** internally (`[]`), so the callback is
99
+ captured once at mount time. If your callback references props or state that
100
+ change over time, those values will be stale. For dynamic callbacks, use
101
+ `useTransformEffect`.
102
+
103
+ ## Requirements
104
+
105
+ Must be called inside a descendant of `TransformWrapper`.
@@ -0,0 +1,192 @@
1
+ import { initialSetup } from "../../constants/state.constants";
2
+
3
+ export const argsTypes = {
4
+ wheel: {
5
+ table: {
6
+ disable: true,
7
+ },
8
+ },
9
+ "wheel.step": {
10
+ defaultValue: initialSetup.wheel.step,
11
+ control: {
12
+ type: "number",
13
+ min: 0,
14
+ },
15
+ table: {
16
+ defaultValue: { summary: "0" },
17
+ },
18
+ },
19
+ "wheel.disabled": {
20
+ defaultValue: initialSetup.wheel.disabled,
21
+ control: { type: "boolean" },
22
+ table: {
23
+ defaultValue: { summary: "false" },
24
+ type: { summary: "boolean" },
25
+ },
26
+ },
27
+ "wheel.wheelDisabled": {
28
+ defaultValue: initialSetup.wheel.wheelDisabled,
29
+ control: { type: "boolean" },
30
+ table: {
31
+ defaultValue: { summary: "false" },
32
+ type: { summary: "boolean" },
33
+ },
34
+ },
35
+ "wheel.touchPadDisabled": {
36
+ defaultValue: initialSetup.wheel.touchPadDisabled,
37
+ control: { type: "boolean" },
38
+ table: {
39
+ defaultValue: { summary: "false" },
40
+ type: { summary: "boolean" },
41
+ },
42
+ },
43
+ "wheel.activationKeys": {
44
+ defaultValue: initialSetup.wheel.activationKeys,
45
+ control: { type: "text" },
46
+ table: {
47
+ defaultValue: { summary: "" },
48
+ type: { summary: "string" },
49
+ },
50
+ },
51
+ "wheel.excluded": {
52
+ defaultValue: initialSetup.wheel.excluded,
53
+ control: { type: "array" },
54
+ table: {
55
+ defaultValue: { summary: "" },
56
+ type: { summary: "array" },
57
+ },
58
+ },
59
+ panning: {
60
+ table: {
61
+ disable: true,
62
+ },
63
+ },
64
+ "panning.disabled": {
65
+ defaultValue: initialSetup.panning.disabled,
66
+ control: { type: "boolean" },
67
+ table: {
68
+ defaultValue: { summary: "false" },
69
+ type: { summary: "boolean" },
70
+ },
71
+ },
72
+ "panning.lockAxisX": {
73
+ defaultValue: initialSetup.panning.lockAxisX,
74
+ control: { type: "boolean" },
75
+ table: {
76
+ defaultValue: { summary: "false" },
77
+ type: { summary: "boolean" },
78
+ },
79
+ },
80
+ "panning.lockAxisY": {
81
+ defaultValue: initialSetup.panning.lockAxisY,
82
+ control: { type: "boolean" },
83
+ table: {
84
+ defaultValue: { summary: "false" },
85
+ type: { summary: "boolean" },
86
+ },
87
+ },
88
+ "panning.activationKeys": {
89
+ defaultValue: initialSetup.panning.activationKeys,
90
+ control: { type: "text" },
91
+ table: {
92
+ defaultValue: { summary: "" },
93
+ type: { summary: "string" },
94
+ },
95
+ },
96
+ "panning.excluded": {
97
+ defaultValue: initialSetup.panning.excluded,
98
+ control: { type: "array" },
99
+ table: {
100
+ defaultValue: { summary: "" },
101
+ type: { summary: "array" },
102
+ },
103
+ },
104
+ pinch: {
105
+ table: {
106
+ disable: true,
107
+ },
108
+ },
109
+ "pinch.step": {
110
+ defaultValue: initialSetup.pinch.step,
111
+ control: {
112
+ type: "number",
113
+ min: 0,
114
+ },
115
+ table: {
116
+ defaultValue: { summary: "0" },
117
+ },
118
+ },
119
+ "pinch.disabled": {
120
+ defaultValue: initialSetup.pinch.disabled,
121
+ control: { type: "boolean" },
122
+ table: {
123
+ defaultValue: { summary: "false" },
124
+ type: { summary: "boolean" },
125
+ },
126
+ },
127
+ "pinch.excluded": {
128
+ defaultValue: initialSetup.pinch.excluded,
129
+ control: { type: "array" },
130
+ table: {
131
+ defaultValue: { summary: "" },
132
+ type: { summary: "array" },
133
+ },
134
+ },
135
+ doubleClick: {
136
+ table: {
137
+ disable: true,
138
+ },
139
+ },
140
+ "doubleClick.step": {
141
+ defaultValue: initialSetup.doubleClick.step,
142
+ control: {
143
+ type: "number",
144
+ min: 0,
145
+ },
146
+ table: {
147
+ defaultValue: { summary: "0" },
148
+ },
149
+ },
150
+ "doubleClick.disabled": {
151
+ defaultValue: initialSetup.doubleClick.disabled,
152
+ control: { type: "boolean" },
153
+ table: {
154
+ defaultValue: { summary: "false" },
155
+ type: { summary: "boolean" },
156
+ },
157
+ },
158
+ "doubleClick.excluded": {
159
+ defaultValue: initialSetup.doubleClick.excluded,
160
+ control: { type: "array" },
161
+ table: {
162
+ defaultValue: { summary: "" },
163
+ type: { summary: "array" },
164
+ },
165
+ },
166
+ };
167
+ // doubleClick: {
168
+ // disabled: false,
169
+ // step: 20,
170
+ // mode: "zoomIn",
171
+ // animation: true,
172
+ // animationType: "easeOut",
173
+ // animationTime: 200,
174
+ // },
175
+ // zoomAnimation: {
176
+ // disabled: false,
177
+ // size: 0.4,
178
+ // animationTime: 200,
179
+ // animationType: "easeOut",
180
+ // },
181
+ // autoAlignment: {
182
+ // disabled: false,
183
+ // size: 30,
184
+ // animationTime: 200,
185
+ // animationType: "easeOut",
186
+ // },
187
+ // velocityAnimation: {
188
+ // disabled: false,
189
+ // sensitivity: 1,
190
+ // animationTime: 600,
191
+ // animationType: "easeOut",
192
+ // },
@@ -0,0 +1,35 @@
1
+ export const normalizeArgs = (args: { [key: string]: any }): any => {
2
+ const newArgs: Record<string, any> = {};
3
+
4
+ Object.keys(args).forEach((key) => {
5
+ const normalizedKey = key.split(".");
6
+ const isNested = normalizedKey.length === 2;
7
+
8
+ if (isNested) {
9
+ if (!newArgs[normalizedKey[0]]) {
10
+ newArgs[normalizedKey[0]] = {};
11
+ }
12
+ newArgs[normalizedKey[0]][normalizedKey[1]] = args[key];
13
+ } else {
14
+ newArgs[key] = args[key];
15
+ }
16
+ });
17
+
18
+ return {
19
+ ...newArgs,
20
+ // DO NOT REMOVE - it will lag out the storybook!!
21
+ onTransform: undefined,
22
+ onWheelStart: undefined,
23
+ onWheel: undefined,
24
+ onWheelStop: undefined,
25
+ onZoomStart: undefined,
26
+ onZoom: undefined,
27
+ onZoomStop: undefined,
28
+ onPanningStart: undefined,
29
+ onPanning: undefined,
30
+ onPanningStop: undefined,
31
+ onPinchStart: undefined,
32
+ onPinch: undefined,
33
+ onPinchStop: undefined,
34
+ };
35
+ };