react-zoom-pan-pinch 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/package.json +3 -2
  2. package/src/stories/assets/big-image.jpeg +0 -0
  3. package/src/stories/assets/map.jpg +0 -0
  4. package/src/stories/assets/medium-image.jpg +0 -0
  5. package/src/stories/assets/pin.svg +0 -1
  6. package/src/stories/assets/small-image.jpg +0 -0
  7. package/src/stories/assets/svg-example.svg +0 -14
  8. package/src/stories/docs/DocTable.tsx +0 -59
  9. package/src/stories/docs/HandlerCards.tsx +0 -102
  10. package/src/stories/docs/Introduction.stories.mdx +0 -135
  11. package/src/stories/docs/PropTable.tsx +0 -116
  12. package/src/stories/docs/docs.module.css +0 -370
  13. package/src/stories/docs/handlers.stories.mdx +0 -7
  14. package/src/stories/docs/handlers.tsx +0 -111
  15. package/src/stories/docs/props.stories.mdx +0 -11
  16. package/src/stories/docs/props.tsx +0 -571
  17. package/src/stories/examples/axis-lock/axis-lock.stories.mdx +0 -35
  18. package/src/stories/examples/axis-lock/example.tsx +0 -114
  19. package/src/stories/examples/bounds/bounds.data.tsx +0 -191
  20. package/src/stories/examples/bounds/bounds.stories.mdx +0 -99
  21. package/src/stories/examples/center-zoomed-out/center-zoomed-out.stories.mdx +0 -206
  22. package/src/stories/examples/cinema/cinema-data.tsx +0 -578
  23. package/src/stories/examples/cinema/cinema.stories.mdx +0 -30
  24. package/src/stories/examples/cinema/example.tsx +0 -378
  25. package/src/stories/examples/cinema/image.png +0 -0
  26. package/src/stories/examples/content/content.stories.mdx +0 -172
  27. package/src/stories/examples/content/mixed-content.data.tsx +0 -624
  28. package/src/stories/examples/content-rerendering/content-updating.stories.mdx +0 -34
  29. package/src/stories/examples/content-rerendering/example.tsx +0 -631
  30. package/src/stories/examples/controls/controls.stories.mdx +0 -120
  31. package/src/stories/examples/image/example.tsx +0 -149
  32. package/src/stories/examples/image/image.stories.mdx +0 -46
  33. package/src/stories/examples/image-annotations/example.tsx +0 -1442
  34. package/src/stories/examples/image-annotations/image-annotations.stories.mdx +0 -39
  35. package/src/stories/examples/image-responsive/example.tsx +0 -152
  36. package/src/stories/examples/image-responsive/image-responsive.stories.mdx +0 -51
  37. package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +0 -107
  38. package/src/stories/examples/initial-transform/example.tsx +0 -233
  39. package/src/stories/examples/initial-transform/initial-transform.stories.mdx +0 -37
  40. package/src/stories/examples/keep-scale/example.tsx +0 -882
  41. package/src/stories/examples/keep-scale/keep-scale.stories.mdx +0 -30
  42. package/src/stories/examples/keep-scale/map.stories.mdx +0 -28
  43. package/src/stories/examples/medical-viewer/chest-xray.tsx +0 -246
  44. package/src/stories/examples/medical-viewer/example.tsx +0 -690
  45. package/src/stories/examples/medical-viewer/medical-viewer.stories.mdx +0 -49
  46. package/src/stories/examples/mini-map/example.tsx +0 -122
  47. package/src/stories/examples/mini-map/mini-map.stories.mdx +0 -26
  48. package/src/stories/examples/miro/example.tsx +0 -1573
  49. package/src/stories/examples/miro/miro.stories.mdx +0 -31
  50. package/src/stories/examples/padding/example.tsx +0 -147
  51. package/src/stories/examples/padding/padding.stories.mdx +0 -35
  52. package/src/stories/examples/product-card/example.tsx +0 -594
  53. package/src/stories/examples/product-card/product-card.stories.mdx +0 -29
  54. package/src/stories/examples/stadium/example.tsx +0 -1040
  55. package/src/stories/examples/stadium/stadium-data.ts +0 -224
  56. package/src/stories/examples/stadium/stadium.stories.mdx +0 -32
  57. package/src/stories/examples/stress/example.tsx +0 -59
  58. package/src/stories/examples/stress/stress-test.stories.mdx +0 -28
  59. package/src/stories/examples/svg-zoom-to-element/creativity.svg +0 -143
  60. package/src/stories/examples/svg-zoom-to-element/example.tsx +0 -95
  61. package/src/stories/examples/svg-zoom-to-element/svg-zoom-to-element.stories.mdx +0 -28
  62. package/src/stories/examples/text-selection/example.tsx +0 -221
  63. package/src/stories/examples/text-selection/text-selection.stories.mdx +0 -31
  64. package/src/stories/examples/velocity/example.tsx +0 -908
  65. package/src/stories/examples/velocity/velocity.stories.mdx +0 -35
  66. package/src/stories/examples/virtualize/example.tsx +0 -239
  67. package/src/stories/examples/virtualize/virtualize.stories.mdx +0 -84
  68. package/src/stories/examples/zoom-to-element/example.tsx +0 -219
  69. package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +0 -31
  70. package/src/stories/hooks/use-controls.stories.mdx +0 -86
  71. package/src/stories/hooks/use-transform-component.stories.mdx +0 -108
  72. package/src/stories/hooks/use-transform-context.stories.mdx +0 -92
  73. package/src/stories/hooks/use-transform-effect.stories.mdx +0 -114
  74. package/src/stories/hooks/use-transform-init.stories.mdx +0 -105
  75. package/src/stories/types/args.types.ts +0 -192
  76. package/src/stories/utils/args.utils.ts +0 -35
  77. package/src/stories/utils/bounds-overlay.tsx +0 -168
  78. package/src/stories/utils/code.utils.tsx +0 -22
  79. package/src/stories/utils/controls.utils.tsx +0 -347
  80. package/src/stories/utils/index.ts +0 -5
  81. package/src/stories/utils/styles.module.css +0 -223
  82. package/src/stories/utils/viewer.styles.ts +0 -34
@@ -1,31 +0,0 @@
1
- import { Meta, Story, ArgsTable, Canvas } from "@storybook/blocks";
2
-
3
- import { TransformWrapper } from "../../../components";
4
- import { argsTypes } from "../../types/args.types.ts";
5
- import { Example } from "./example";
6
-
7
- export const Template = (args) => <Example {...args} />;
8
-
9
- <Meta title="Examples/Miro" component={TransformWrapper} argTypes={argsTypes} />
10
-
11
- # Miro
12
-
13
- A **Miro-style** canvas interaction: hold `Cmd` (or `Ctrl`) and scroll to
14
- zoom, or use the trackpad freely to pan. The `activationKeys` option accepts
15
- a function that receives the currently held keys, letting you create
16
- conditional gesture activation.
17
-
18
- The board below is built with HTML/CSS (sticky notes, frames, flow steps, and a
19
- light dot grid) on a **large infinite-style canvas** so zoom and pan feel like a
20
- real whiteboard tool.
21
-
22
- This pattern separates zoom from scroll — ideal for infinite canvas apps
23
- where the default scroll behavior should pan, not zoom.
24
-
25
- <Canvas>
26
- <Story name="Miro">{(args) => <Template {...args} />}</Story>
27
- </Canvas>
28
-
29
- ## Component API
30
-
31
- <ArgsTable story="Miro" />
@@ -1,147 +0,0 @@
1
- import React, { useState } from "react";
2
-
3
- import { TransformWrapper, TransformComponent } from "../../../components";
4
- import { Controls, ToggleIcon, normalizeArgs, viewerChrome } from "../../utils";
5
- import { useTransformComponent } from "../../../hooks";
6
- import exampleImg from "../../assets/medium-image.jpg";
7
-
8
- function ModeBadge({ disabled }: { disabled: boolean }) {
9
- return (
10
- <div
11
- style={{
12
- position: "absolute",
13
- top: 16,
14
- right: 16,
15
- zIndex: 10,
16
- padding: "5px 12px",
17
- borderRadius: 8,
18
- background: "rgba(10, 10, 18, 0.78)",
19
- backdropFilter: "blur(12px)",
20
- WebkitBackdropFilter: "blur(12px)",
21
- border: `1px solid ${disabled ? "rgba(239, 68, 68, 0.3)" : "rgba(52, 211, 153, 0.3)"}`,
22
- display: "flex",
23
- alignItems: "center",
24
- gap: 8,
25
- fontFamily: "system-ui, -apple-system, sans-serif",
26
- userSelect: "none",
27
- pointerEvents: "none",
28
- }}
29
- >
30
- <span
31
- style={{
32
- width: 6,
33
- height: 6,
34
- borderRadius: "50%",
35
- background: disabled ? "#ef4444" : "#34d399",
36
- boxShadow: `0 0 8px ${disabled ? "rgba(239,68,68,0.5)" : "rgba(52,211,153,0.5)"}`,
37
- }}
38
- />
39
- <span
40
- style={{
41
- fontSize: 11,
42
- fontWeight: 600,
43
- color: disabled ? "rgba(239,68,68,0.8)" : "rgba(52,211,153,0.8)",
44
- letterSpacing: "0.04em",
45
- }}
46
- >
47
- Padding {disabled ? "OFF" : "ON"}
48
- </span>
49
- </div>
50
- );
51
- }
52
-
53
- function ScaleBadge() {
54
- return useTransformComponent(({ state }) => (
55
- <div
56
- style={{
57
- position: "absolute",
58
- bottom: 16,
59
- right: 16,
60
- zIndex: 10,
61
- padding: "5px 12px",
62
- borderRadius: 8,
63
- background: "rgba(10, 10, 18, 0.78)",
64
- backdropFilter: "blur(12px)",
65
- WebkitBackdropFilter: "blur(12px)",
66
- border: "1px solid rgba(255,255,255,0.1)",
67
- color: "rgba(255,255,255,0.7)",
68
- fontSize: 11,
69
- fontWeight: 600,
70
- fontFamily: "system-ui, -apple-system, sans-serif",
71
- letterSpacing: "0.02em",
72
- userSelect: "none",
73
- pointerEvents: "none",
74
- }}
75
- >
76
- {state.scale.toFixed(2)}x
77
- </div>
78
- ));
79
- }
80
-
81
- export const Example: React.FC<any> = (args: any) => {
82
- const [disablePadding, setDisablePadding] = useState(false);
83
-
84
- return (
85
- <div style={{ fontFamily: "system-ui, -apple-system, sans-serif" }}>
86
- <TransformWrapper
87
- {...normalizeArgs(args)}
88
- disablePadding={disablePadding}
89
- key={String(disablePadding)}
90
- >
91
- {(utils) => (
92
- <>
93
- <Controls
94
- {...utils}
95
- extraButtons={[
96
- {
97
- label: disablePadding ? "Enable padding" : "Disable padding",
98
- icon: <ToggleIcon />,
99
- onClick: () => setDisablePadding((prev) => !prev),
100
- },
101
- ]}
102
- />
103
- <ModeBadge disabled={disablePadding} />
104
- <div style={{ position: "relative", display: "inline-block" }}>
105
- <TransformComponent
106
- wrapperStyle={{
107
- ...viewerChrome,
108
- width: "500px",
109
- height: "500px",
110
- maxWidth: "80vw",
111
- maxHeight: "75vh",
112
- }}
113
- >
114
- <img src={exampleImg} alt="" style={{ display: "block" }} />
115
- </TransformComponent>
116
- <ScaleBadge />
117
- </div>
118
- </>
119
- )}
120
- </TransformWrapper>
121
- <p
122
- style={{
123
- fontSize: "13px",
124
- color: "#888",
125
- marginTop: "12px",
126
- maxWidth: "500px",
127
- lineHeight: 1.5,
128
- }}
129
- >
130
- {disablePadding ? (
131
- <>
132
- <strong>Padding is OFF.</strong> Zoom is strictly clamped — you
133
- cannot zoom past the content boundaries. The content snaps to the
134
- edge immediately.
135
- </>
136
- ) : (
137
- <>
138
- <strong>Padding is ON</strong> (default). When zooming past the
139
- content boundaries, you get an elastic &ldquo;overscroll&rdquo;
140
- effect — the content stretches slightly beyond the limit, then snaps
141
- back with a smooth animation.
142
- </>
143
- )}
144
- </p>
145
- </div>
146
- );
147
- };
@@ -1,35 +0,0 @@
1
- import { Meta, Story, ArgsTable, Canvas } from "@storybook/blocks";
2
-
3
- import { TransformWrapper } from "../../../components";
4
- import { argsTypes } from "../../types/args.types.ts";
5
- import { Example } from "./example";
6
-
7
- export const Template = (args) => <Example {...args} />;
8
-
9
- <Meta
10
- title="Basic/Padding"
11
- component={TransformWrapper}
12
- argTypes={argsTypes}
13
- />
14
-
15
- # Padding
16
-
17
- The **padding** effect controls what happens when the user zooms past the
18
- content boundaries. By default (`disablePadding: false`), the library allows a
19
- small elastic overscroll — the content stretches slightly beyond the limit, then
20
- snaps back with a smooth animation. This gives a natural, tactile feel similar
21
- to iOS scroll bounce.
22
-
23
- When `disablePadding` is set to `true`, the zoom is strictly clamped: the
24
- content stops exactly at the boundary with no overscroll or snap-back animation.
25
-
26
- Use the **toggle button** in the control bar to switch between the two modes in
27
- real time and feel the difference. The status badge shows the current mode.
28
-
29
- <Canvas>
30
- <Story name="Padding">{(args) => <Template {...args} />}</Story>
31
- </Canvas>
32
-
33
- ## Component API
34
-
35
- <ArgsTable story="Padding" />