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,624 @@
1
+ import React, { useState } from "react";
2
+
3
+ const FONT = "system-ui, -apple-system, 'Segoe UI', sans-serif";
4
+
5
+ const palette = {
6
+ bg: "#0c0c1d",
7
+ surface: "#161633",
8
+ surfaceAlt: "#1c1c40",
9
+ border: "rgba(255,255,255,0.06)",
10
+ borderHover: "rgba(255,255,255,0.12)",
11
+ text: "#e4e4f0",
12
+ textMuted: "#8888a8",
13
+ accent: "#6c63ff",
14
+ accentGlow: "rgba(108,99,255,0.25)",
15
+ panZone: "#ff4d6a",
16
+ panZoneBg: "rgba(255,77,106,0.08)",
17
+ panZoneBorder: "rgba(255,77,106,0.25)",
18
+ wheelZone: "#3dc9f6",
19
+ wheelZoneBg: "rgba(61,201,246,0.08)",
20
+ wheelZoneBorder: "rgba(61,201,246,0.25)",
21
+ pinchZone: "#43e97b",
22
+ pinchZoneBg: "rgba(67,233,123,0.08)",
23
+ pinchZoneBorder: "rgba(67,233,123,0.25)",
24
+ };
25
+
26
+ function ZoneBadge({ color, label }: { color: string; label: string }) {
27
+ return (
28
+ <span
29
+ style={{
30
+ display: "inline-flex",
31
+ alignItems: "center",
32
+ gap: "5px",
33
+ padding: "3px 10px",
34
+ borderRadius: "100px",
35
+ fontSize: "10px",
36
+ fontWeight: 700,
37
+ letterSpacing: "0.6px",
38
+ textTransform: "uppercase",
39
+ color,
40
+ background: `${color}15`,
41
+ border: `1px solid ${color}40`,
42
+ fontFamily: FONT,
43
+ }}
44
+ >
45
+ <span
46
+ style={{
47
+ width: 6,
48
+ height: 6,
49
+ borderRadius: "50%",
50
+ background: color,
51
+ boxShadow: `0 0 6px ${color}80`,
52
+ }}
53
+ />
54
+ {label}
55
+ </span>
56
+ );
57
+ }
58
+
59
+ function SectionTitle({ children }: { children: React.ReactNode }) {
60
+ return (
61
+ <h3
62
+ style={{
63
+ margin: "0 0 12px 0",
64
+ fontSize: "13px",
65
+ fontWeight: 600,
66
+ letterSpacing: "0.8px",
67
+ textTransform: "uppercase",
68
+ color: palette.textMuted,
69
+ fontFamily: FONT,
70
+ }}
71
+ >
72
+ {children}
73
+ </h3>
74
+ );
75
+ }
76
+
77
+ function StatCard({
78
+ label,
79
+ value,
80
+ trend,
81
+ color,
82
+ }: {
83
+ label: string;
84
+ value: string;
85
+ trend: string;
86
+ color: string;
87
+ }) {
88
+ return (
89
+ <div
90
+ style={{
91
+ flex: "1 1 0",
92
+ minWidth: 110,
93
+ padding: "16px",
94
+ borderRadius: "12px",
95
+ background: palette.surface,
96
+ border: `1px solid ${palette.border}`,
97
+ }}
98
+ >
99
+ <div
100
+ style={{
101
+ fontSize: "11px",
102
+ color: palette.textMuted,
103
+ marginBottom: "6px",
104
+ fontFamily: FONT,
105
+ fontWeight: 500,
106
+ }}
107
+ >
108
+ {label}
109
+ </div>
110
+ <div
111
+ style={{
112
+ fontSize: "22px",
113
+ fontWeight: 700,
114
+ color: palette.text,
115
+ fontFamily: FONT,
116
+ lineHeight: 1.1,
117
+ }}
118
+ >
119
+ {value}
120
+ </div>
121
+ <div
122
+ style={{
123
+ fontSize: "11px",
124
+ fontWeight: 600,
125
+ color,
126
+ marginTop: "6px",
127
+ fontFamily: FONT,
128
+ }}
129
+ >
130
+ {trend}
131
+ </div>
132
+ </div>
133
+ );
134
+ }
135
+
136
+ function InteractiveButtons() {
137
+ const [count, setCount] = useState(0);
138
+
139
+ return (
140
+ <div style={{ display: "flex", gap: "8px", flexWrap: "wrap" }}>
141
+ <button
142
+ type="button"
143
+ onClick={() => setCount((c) => c + 1)}
144
+ style={{
145
+ padding: "8px 18px",
146
+ borderRadius: "8px",
147
+ border: `1px solid ${palette.accent}`,
148
+ background: `linear-gradient(135deg, ${palette.accent}, #8b5cf6)`,
149
+ color: "#fff",
150
+ fontSize: "12px",
151
+ fontWeight: 600,
152
+ fontFamily: FONT,
153
+ cursor: "pointer",
154
+ boxShadow: `0 2px 12px ${palette.accentGlow}`,
155
+ transition: "transform 0.1s",
156
+ }}
157
+ >
158
+ Clicked {count} times
159
+ </button>
160
+ <button
161
+ type="button"
162
+ onClick={() => setCount(0)}
163
+ style={{
164
+ padding: "8px 18px",
165
+ borderRadius: "8px",
166
+ border: `1px solid ${palette.border}`,
167
+ background: palette.surfaceAlt,
168
+ color: palette.textMuted,
169
+ fontSize: "12px",
170
+ fontWeight: 600,
171
+ fontFamily: FONT,
172
+ cursor: "pointer",
173
+ }}
174
+ >
175
+ Reset
176
+ </button>
177
+ </div>
178
+ );
179
+ }
180
+
181
+ function ScrollableList() {
182
+ const items = [
183
+ { name: "Authentication", status: "active", color: "#43e97b" },
184
+ { name: "Database Sync", status: "active", color: "#43e97b" },
185
+ { name: "CDN Cache", status: "warning", color: "#f6d365" },
186
+ { name: "WebSocket", status: "active", color: "#43e97b" },
187
+ { name: "Rate Limiter", status: "active", color: "#43e97b" },
188
+ { name: "Email Queue", status: "degraded", color: "#ff9a44" },
189
+ { name: "Search Index", status: "active", color: "#43e97b" },
190
+ { name: "Cron Jobs", status: "active", color: "#43e97b" },
191
+ ];
192
+
193
+ return (
194
+ <div
195
+ style={{
196
+ maxHeight: "160px",
197
+ overflowY: "auto",
198
+ borderRadius: "10px",
199
+ border: `1px solid ${palette.border}`,
200
+ background: palette.surface,
201
+ }}
202
+ >
203
+ {items.map((item) => (
204
+ <div
205
+ key={item.name}
206
+ style={{
207
+ display: "flex",
208
+ alignItems: "center",
209
+ justifyContent: "space-between",
210
+ padding: "10px 14px",
211
+ borderBottom: `1px solid ${palette.border}`,
212
+ fontSize: "12px",
213
+ fontFamily: FONT,
214
+ }}
215
+ >
216
+ <span style={{ color: palette.text, fontWeight: 500 }}>
217
+ {item.name}
218
+ </span>
219
+ <span
220
+ style={{
221
+ display: "flex",
222
+ alignItems: "center",
223
+ gap: "5px",
224
+ color: item.color,
225
+ fontWeight: 600,
226
+ fontSize: "11px",
227
+ textTransform: "capitalize",
228
+ }}
229
+ >
230
+ <span
231
+ style={{
232
+ width: 6,
233
+ height: 6,
234
+ borderRadius: "50%",
235
+ background: item.color,
236
+ boxShadow: `0 0 6px ${item.color}80`,
237
+ }}
238
+ />
239
+ {item.status}
240
+ </span>
241
+ </div>
242
+ ))}
243
+ </div>
244
+ );
245
+ }
246
+
247
+ function MiniBarChart() {
248
+ const bars = [35, 55, 40, 75, 60, 85, 45, 70, 90, 50, 65, 80];
249
+ const maxH = 60;
250
+
251
+ return (
252
+ <div
253
+ style={{
254
+ display: "flex",
255
+ alignItems: "flex-end",
256
+ gap: "4px",
257
+ height: maxH,
258
+ padding: "12px 0 0",
259
+ }}
260
+ >
261
+ {bars.map((v) => (
262
+ <div
263
+ key={v}
264
+ style={{
265
+ flex: "1 1 0",
266
+ height: `${(v / 100) * maxH}px`,
267
+ borderRadius: "4px 4px 0 0",
268
+ background: `linear-gradient(180deg, ${palette.accent}cc, ${palette.accent}44)`,
269
+ minWidth: 0,
270
+ }}
271
+ />
272
+ ))}
273
+ </div>
274
+ );
275
+ }
276
+
277
+ function ExclusionZone({
278
+ className,
279
+ color,
280
+ bgColor,
281
+ borderColor,
282
+ label,
283
+ description,
284
+ children,
285
+ }: {
286
+ className: string;
287
+ color: string;
288
+ bgColor: string;
289
+ borderColor: string;
290
+ label: string;
291
+ description: string;
292
+ children: React.ReactNode;
293
+ }) {
294
+ return (
295
+ <div
296
+ className={className}
297
+ style={{
298
+ position: "relative",
299
+ padding: "16px",
300
+ borderRadius: "12px",
301
+ background: bgColor,
302
+ border: `1.5px dashed ${borderColor}`,
303
+ }}
304
+ >
305
+ <div
306
+ style={{
307
+ display: "flex",
308
+ alignItems: "center",
309
+ justifyContent: "space-between",
310
+ marginBottom: "10px",
311
+ }}
312
+ >
313
+ <ZoneBadge color={color} label={label} />
314
+ </div>
315
+ <div
316
+ style={{
317
+ fontSize: "11.5px",
318
+ color: palette.textMuted,
319
+ fontFamily: FONT,
320
+ lineHeight: 1.5,
321
+ marginBottom: "12px",
322
+ }}
323
+ >
324
+ {description}
325
+ </div>
326
+ {children}
327
+ </div>
328
+ );
329
+ }
330
+
331
+ export function MixedContent() {
332
+ return (
333
+ <div
334
+ style={{
335
+ width: 780,
336
+ padding: "32px",
337
+ background: palette.bg,
338
+ fontFamily: FONT,
339
+ color: palette.text,
340
+ }}
341
+ >
342
+ {/* Header */}
343
+ <div style={{ marginBottom: "28px" }}>
344
+ <div
345
+ style={{
346
+ display: "flex",
347
+ alignItems: "center",
348
+ gap: "10px",
349
+ marginBottom: "6px",
350
+ }}
351
+ >
352
+ <div
353
+ style={{
354
+ width: 32,
355
+ height: 32,
356
+ borderRadius: "10px",
357
+ background: `linear-gradient(135deg, ${palette.accent}, #8b5cf6)`,
358
+ display: "flex",
359
+ alignItems: "center",
360
+ justifyContent: "center",
361
+ fontSize: "15px",
362
+ fontWeight: 800,
363
+ color: "#fff",
364
+ boxShadow: `0 2px 16px ${palette.accentGlow}`,
365
+ }}
366
+ >
367
+ Z
368
+ </div>
369
+ <h1
370
+ style={{
371
+ margin: 0,
372
+ fontSize: "20px",
373
+ fontWeight: 700,
374
+ letterSpacing: "-0.3px",
375
+ background: "linear-gradient(135deg, #fff 30%, #8888a8 100%)",
376
+ WebkitBackgroundClip: "text",
377
+ WebkitTextFillColor: "transparent",
378
+ }}
379
+ >
380
+ Mixed Content Dashboard
381
+ </h1>
382
+ </div>
383
+ <p
384
+ style={{
385
+ margin: 0,
386
+ fontSize: "13px",
387
+ color: palette.textMuted,
388
+ lineHeight: 1.5,
389
+ }}
390
+ >
391
+ Pan, zoom, and pinch this entire canvas. Colored zones below disable
392
+ specific gestures — try interacting with each one.
393
+ </p>
394
+ </div>
395
+
396
+ {/* Exclusion zones */}
397
+ <SectionTitle>Exclusion Zones</SectionTitle>
398
+ <div
399
+ style={{
400
+ display: "flex",
401
+ flexDirection: "column",
402
+ gap: "14px",
403
+ marginBottom: "24px",
404
+ }}
405
+ >
406
+ {/* Panning disabled */}
407
+ <ExclusionZone
408
+ className="panningDisabled"
409
+ color={palette.panZone}
410
+ bgColor={palette.panZoneBg}
411
+ borderColor={palette.panZoneBorder}
412
+ label="Panning Disabled"
413
+ description={
414
+ 'This zone has the CSS class "panningDisabled" — clicking and dragging inside here will NOT pan the canvas. Useful for scrollable lists, text selection areas, or embedded interactive widgets.'
415
+ }
416
+ >
417
+ <ScrollableList />
418
+ </ExclusionZone>
419
+
420
+ {/* Wheel disabled */}
421
+ <ExclusionZone
422
+ className="wheelDisabled"
423
+ color={palette.wheelZone}
424
+ bgColor={palette.wheelZoneBg}
425
+ borderColor={palette.wheelZoneBorder}
426
+ label="Wheel Disabled"
427
+ description={
428
+ 'This zone has the CSS class "wheelDisabled" — scrolling the mouse wheel here will NOT zoom the canvas. Perfect for scrollable content inside the transform viewport.'
429
+ }
430
+ >
431
+ <InteractiveButtons />
432
+ </ExclusionZone>
433
+
434
+ {/* Pinch disabled */}
435
+ <ExclusionZone
436
+ className="pinchDisabled"
437
+ color={palette.pinchZone}
438
+ bgColor={palette.pinchZoneBg}
439
+ borderColor={palette.pinchZoneBorder}
440
+ label="Pinch Disabled"
441
+ description={
442
+ 'This zone has the CSS class "pinchDisabled" — pinch gestures on touch devices will NOT zoom the canvas. Ideal for embedded maps, canvases, or multi-touch widgets.'
443
+ }
444
+ >
445
+ <div
446
+ style={{
447
+ display: "grid",
448
+ gridTemplateColumns: "1fr 1fr",
449
+ gap: "8px",
450
+ }}
451
+ >
452
+ {[
453
+ { label: "Scale X", val: "1.00" },
454
+ { label: "Scale Y", val: "1.00" },
455
+ { label: "Rotation", val: "0°" },
456
+ { label: "Opacity", val: "100%" },
457
+ ].map((item) => (
458
+ <div
459
+ key={item.label}
460
+ style={{
461
+ padding: "10px 12px",
462
+ borderRadius: "8px",
463
+ background: palette.surface,
464
+ border: `1px solid ${palette.border}`,
465
+ fontSize: "11px",
466
+ fontFamily: FONT,
467
+ }}
468
+ >
469
+ <div
470
+ style={{
471
+ color: palette.textMuted,
472
+ marginBottom: "3px",
473
+ fontWeight: 500,
474
+ }}
475
+ >
476
+ {item.label}
477
+ </div>
478
+ <div style={{ color: palette.text, fontWeight: 700 }}>
479
+ {item.val}
480
+ </div>
481
+ </div>
482
+ ))}
483
+ </div>
484
+ </ExclusionZone>
485
+ </div>
486
+
487
+ {/* Stat cards */}
488
+ <div
489
+ style={{
490
+ display: "flex",
491
+ gap: "12px",
492
+ marginBottom: "24px",
493
+ flexWrap: "wrap",
494
+ }}
495
+ >
496
+ <StatCard
497
+ label="Active Users"
498
+ value="12,847"
499
+ trend="+ 14.2% this week"
500
+ color="#43e97b"
501
+ />
502
+ <StatCard
503
+ label="Requests / sec"
504
+ value="3,291"
505
+ trend="+ 8.6% avg"
506
+ color="#3dc9f6"
507
+ />
508
+ <StatCard
509
+ label="Error Rate"
510
+ value="0.12%"
511
+ trend="- 0.03% improved"
512
+ color="#43e97b"
513
+ />
514
+ <StatCard
515
+ label="Latency (p99)"
516
+ value="142ms"
517
+ trend="- 18ms faster"
518
+ color="#3dc9f6"
519
+ />
520
+ </div>
521
+
522
+ {/* Chart */}
523
+ <div
524
+ style={{
525
+ padding: "16px",
526
+ borderRadius: "12px",
527
+ background: palette.surface,
528
+ border: `1px solid ${palette.border}`,
529
+ marginBottom: "24px",
530
+ }}
531
+ >
532
+ <div
533
+ style={{
534
+ display: "flex",
535
+ alignItems: "center",
536
+ justifyContent: "space-between",
537
+ marginBottom: "4px",
538
+ }}
539
+ >
540
+ <span
541
+ style={{
542
+ fontSize: "12px",
543
+ fontWeight: 600,
544
+ color: palette.textMuted,
545
+ letterSpacing: "0.5px",
546
+ textTransform: "uppercase",
547
+ }}
548
+ >
549
+ Throughput — Last 12 hours
550
+ </span>
551
+ <span
552
+ style={{
553
+ fontSize: "11px",
554
+ color: palette.accent,
555
+ fontWeight: 600,
556
+ }}
557
+ >
558
+ Live
559
+ </span>
560
+ </div>
561
+ <MiniBarChart />
562
+ <div
563
+ style={{
564
+ display: "flex",
565
+ justifyContent: "space-between",
566
+ marginTop: "4px",
567
+ fontSize: "10px",
568
+ color: palette.textMuted,
569
+ }}
570
+ >
571
+ <span>00:00</span>
572
+ <span>06:00</span>
573
+ <span>12:00</span>
574
+ </div>
575
+ </div>
576
+
577
+ {/* Footer note */}
578
+ <div
579
+ style={{
580
+ marginTop: "24px",
581
+ padding: "14px 16px",
582
+ borderRadius: "10px",
583
+ background: palette.surfaceAlt,
584
+ border: `1px solid ${palette.border}`,
585
+ display: "flex",
586
+ alignItems: "flex-start",
587
+ gap: "10px",
588
+ }}
589
+ >
590
+ <span
591
+ style={{
592
+ width: 20,
593
+ height: 20,
594
+ borderRadius: "50%",
595
+ background: palette.accent,
596
+ color: "#fff",
597
+ display: "flex",
598
+ alignItems: "center",
599
+ justifyContent: "center",
600
+ fontSize: "11px",
601
+ fontWeight: 800,
602
+ flexShrink: 0,
603
+ marginTop: "1px",
604
+ }}
605
+ >
606
+ i
607
+ </span>
608
+ <p
609
+ style={{
610
+ margin: 0,
611
+ fontSize: "12px",
612
+ color: palette.textMuted,
613
+ lineHeight: 1.6,
614
+ }}
615
+ >
616
+ Everything outside the dashed zones responds to all gestures normally
617
+ — try panning the stat cards, zooming on the chart, or pinching to
618
+ zoom the entire dashboard. The exclusion zones use simple CSS class
619
+ names; no JavaScript wiring required.
620
+ </p>
621
+ </div>
622
+ </div>
623
+ );
624
+ }
@@ -0,0 +1,34 @@
1
+ import { Meta, Story, ArgsTable, Canvas } from "@storybook/blocks";
2
+
3
+ import { TransformWrapper, TransformComponent } from "../../../components";
4
+ import { argsTypes } from "../../types/args.types";
5
+ import { Example } from "./example";
6
+
7
+ export const Template = (args) => <Example {...args} />;
8
+
9
+ <Meta
10
+ title="Basic/Rerendering"
11
+ component={TransformWrapper}
12
+ argTypes={argsTypes}
13
+ />
14
+
15
+ # Rerendering
16
+
17
+ Proves that **frequent React re-renders** inside `TransformComponent` do not
18
+ disrupt the current zoom or pan state. Three regions update on independent
19
+ timers (1 s, 3 s, 12 s). Each toggle is not a text swap — it **restructures the
20
+ layout**: compact card vs three-column grid, sidebar split vs hero + stats +
21
+ two-column dashboard, minimal strip vs tall stack with gallery, list rows, and
22
+ footer. Total content height changes a lot between states.
23
+
24
+ Zoom in, pan around, and watch the layout reflow without resetting your
25
+ viewport. This matters for dashboards, live data, and any UI where structure and
26
+ size change under the user’s feet.
27
+
28
+ <Canvas>
29
+ <Story name="Rerendering">{(args) => <Template {...args} />}</Story>
30
+ </Canvas>
31
+
32
+ ## Component API
33
+
34
+ <ArgsTable story="Rerendering" />