react-zoom-pan-pinch 3.6.1 → 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.
- package/dist/index.cjs.js +770 -277
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +116 -22
- package/dist/index.esm.js +766 -269
- package/dist/index.esm.js.map +1 -1
- package/package.json +73 -60
- package/src/components/index.ts +5 -0
- package/src/components/keep-scale/keep-scale.tsx +28 -0
- package/src/components/mini-map/mini-map.tsx +292 -0
- package/src/components/mini-map/use-resize.hook.ts +74 -0
- package/src/components/transform-component/transform-component.module.css +43 -0
- package/src/components/transform-component/transform-component.tsx +96 -0
- package/src/components/transform-wrapper/transform-wrapper.tsx +39 -0
- package/src/components/virtualize/virtualize.tsx +133 -0
- package/src/components/virtualize/virtualize.utils.ts +104 -0
- package/src/constants/state.constants.ts +99 -0
- package/src/core/animations/animations.constants.ts +78 -0
- package/src/core/animations/animations.utils.ts +115 -0
- package/src/core/bounds/bounds.types.ts +8 -0
- package/src/core/bounds/bounds.utils.ts +226 -0
- package/src/core/double-click/double-click.logic.ts +127 -0
- package/src/core/handlers/handlers.logic.ts +122 -0
- package/src/core/handlers/handlers.utils.ts +243 -0
- package/src/core/instance.core.ts +704 -0
- package/src/core/pan/panning.logic.ts +122 -0
- package/src/core/pan/panning.utils.ts +216 -0
- package/src/core/pan/velocity.logic.ts +187 -0
- package/src/core/pan/velocity.utils.ts +83 -0
- package/src/core/pinch/pinch.logic.ts +139 -0
- package/src/core/pinch/pinch.utils.ts +95 -0
- package/src/core/wheel/wheel.logic.ts +161 -0
- package/src/core/wheel/wheel.utils.ts +157 -0
- package/src/core/zoom/zoom.logic.ts +71 -0
- package/src/core/zoom/zoom.utils.ts +62 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/use-controls.tsx +9 -0
- package/src/hooks/use-transform-component.tsx +30 -0
- package/src/hooks/use-transform-context.tsx +13 -0
- package/src/hooks/use-transform-effect.tsx +22 -0
- package/src/hooks/use-transform-init.tsx +28 -0
- package/src/hooks/use-zoom-pan-pinch.tsx +48 -0
- package/src/index.ts +6 -0
- package/src/models/calculations.model.ts +34 -0
- package/src/models/context.model.ts +218 -0
- package/src/models/helpers.model.ts +15 -0
- package/src/models/index.ts +3 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/stories/assets/big-image.jpeg +0 -0
- package/src/stories/assets/map.jpg +0 -0
- package/src/stories/assets/medium-image.jpg +0 -0
- package/src/stories/assets/pin.svg +1 -0
- package/src/stories/assets/small-image.jpg +0 -0
- package/src/stories/assets/svg-example.svg +14 -0
- package/src/stories/docs/DocTable.tsx +59 -0
- package/src/stories/docs/HandlerCards.tsx +102 -0
- package/src/stories/docs/Introduction.stories.mdx +135 -0
- package/src/stories/docs/PropTable.tsx +116 -0
- package/src/stories/docs/docs.module.css +370 -0
- package/src/stories/docs/handlers.stories.mdx +7 -0
- package/src/stories/docs/handlers.tsx +111 -0
- package/src/stories/docs/props.stories.mdx +11 -0
- package/src/stories/docs/props.tsx +571 -0
- package/src/stories/examples/axis-lock/axis-lock.stories.mdx +35 -0
- package/src/stories/examples/axis-lock/example.tsx +114 -0
- package/src/stories/examples/bounds/bounds.data.tsx +191 -0
- package/src/stories/examples/bounds/bounds.stories.mdx +99 -0
- package/src/stories/examples/center-zoomed-out/center-zoomed-out.stories.mdx +206 -0
- package/src/stories/examples/cinema/cinema-data.tsx +578 -0
- package/src/stories/examples/cinema/cinema.stories.mdx +30 -0
- package/src/stories/examples/cinema/example.tsx +378 -0
- package/src/stories/examples/cinema/image.png +0 -0
- package/src/stories/examples/content/content.stories.mdx +172 -0
- package/src/stories/examples/content/mixed-content.data.tsx +624 -0
- package/src/stories/examples/content-rerendering/content-updating.stories.mdx +34 -0
- package/src/stories/examples/content-rerendering/example.tsx +631 -0
- package/src/stories/examples/controls/controls.stories.mdx +120 -0
- package/src/stories/examples/image/example.tsx +149 -0
- package/src/stories/examples/image/image.stories.mdx +46 -0
- package/src/stories/examples/image-annotations/example.tsx +1442 -0
- package/src/stories/examples/image-annotations/image-annotations.stories.mdx +39 -0
- package/src/stories/examples/image-responsive/example.tsx +152 -0
- package/src/stories/examples/image-responsive/image-responsive.stories.mdx +51 -0
- package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +107 -0
- package/src/stories/examples/initial-transform/example.tsx +233 -0
- package/src/stories/examples/initial-transform/initial-transform.stories.mdx +37 -0
- package/src/stories/examples/keep-scale/example.tsx +882 -0
- package/src/stories/examples/keep-scale/keep-scale.stories.mdx +30 -0
- package/src/stories/examples/keep-scale/map.stories.mdx +28 -0
- package/src/stories/examples/medical-viewer/chest-xray.tsx +246 -0
- package/src/stories/examples/medical-viewer/example.tsx +690 -0
- package/src/stories/examples/medical-viewer/medical-viewer.stories.mdx +49 -0
- package/src/stories/examples/mini-map/example.tsx +122 -0
- package/src/stories/examples/mini-map/mini-map.stories.mdx +26 -0
- package/src/stories/examples/miro/example.tsx +1573 -0
- package/src/stories/examples/miro/miro.stories.mdx +31 -0
- package/src/stories/examples/padding/example.tsx +147 -0
- package/src/stories/examples/padding/padding.stories.mdx +35 -0
- package/src/stories/examples/product-card/example.tsx +594 -0
- package/src/stories/examples/product-card/product-card.stories.mdx +29 -0
- package/src/stories/examples/stadium/example.tsx +1040 -0
- package/src/stories/examples/stadium/stadium-data.ts +224 -0
- package/src/stories/examples/stadium/stadium.stories.mdx +32 -0
- package/src/stories/examples/stress/example.tsx +59 -0
- package/src/stories/examples/stress/stress-test.stories.mdx +28 -0
- package/src/stories/examples/svg-zoom-to-element/creativity.svg +143 -0
- package/src/stories/examples/svg-zoom-to-element/example.tsx +95 -0
- package/src/stories/examples/svg-zoom-to-element/svg-zoom-to-element.stories.mdx +28 -0
- package/src/stories/examples/text-selection/example.tsx +221 -0
- package/src/stories/examples/text-selection/text-selection.stories.mdx +31 -0
- package/src/stories/examples/velocity/example.tsx +908 -0
- package/src/stories/examples/velocity/velocity.stories.mdx +35 -0
- package/src/stories/examples/virtualize/example.tsx +239 -0
- package/src/stories/examples/virtualize/virtualize.stories.mdx +84 -0
- package/src/stories/examples/zoom-to-element/example.tsx +219 -0
- package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +31 -0
- package/src/stories/hooks/use-controls.stories.mdx +86 -0
- package/src/stories/hooks/use-transform-component.stories.mdx +108 -0
- package/src/stories/hooks/use-transform-context.stories.mdx +92 -0
- package/src/stories/hooks/use-transform-effect.stories.mdx +114 -0
- package/src/stories/hooks/use-transform-init.stories.mdx +105 -0
- package/src/stories/types/args.types.ts +192 -0
- package/src/stories/utils/args.utils.ts +35 -0
- package/src/stories/utils/bounds-overlay.tsx +168 -0
- package/src/stories/utils/code.utils.tsx +22 -0
- package/src/stories/utils/controls.utils.tsx +347 -0
- package/src/stories/utils/index.ts +5 -0
- package/src/stories/utils/styles.module.css +223 -0
- package/src/stories/utils/viewer.styles.ts +34 -0
- package/src/styles.css +8 -0
- package/src/typings.d.ts +21 -0
- package/src/utils/calculations.utils.ts +16 -0
- package/src/utils/callback.utils.ts +11 -0
- package/src/utils/context.utils.ts +49 -0
- package/src/utils/event.utils.ts +38 -0
- package/src/utils/helpers.utils.ts +22 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/ref.utils.ts +32 -0
- package/src/utils/state.utils.ts +77 -0
- package/src/utils/styles.utils.ts +49 -0
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { TransformComponent, TransformWrapper } from "components";
|
|
4
|
+
import { Controls, normalizeArgs } from "../../utils";
|
|
5
|
+
import { viewerFrame } from "../../utils/viewer.styles";
|
|
6
|
+
|
|
7
|
+
const BLOCKS = [
|
|
8
|
+
{ interval: 1000, label: "Block A", color: "#667eea", desc: "1 s cycle" },
|
|
9
|
+
{ interval: 3000, label: "Block B", color: "#f093fb", desc: "3 s cycle" },
|
|
10
|
+
{ interval: 12000, label: "Block C", color: "#43e97b", desc: "12 s cycle" },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
function StatusDot({ active, color }: { active: boolean; color: string }) {
|
|
14
|
+
return (
|
|
15
|
+
<span
|
|
16
|
+
style={{
|
|
17
|
+
display: "inline-block",
|
|
18
|
+
width: 6,
|
|
19
|
+
height: 6,
|
|
20
|
+
borderRadius: "50%",
|
|
21
|
+
background: active ? color : "rgba(255,255,255,0.15)",
|
|
22
|
+
boxShadow: active ? `0 0 8px ${color}88` : "none",
|
|
23
|
+
transition: "all 0.3s ease",
|
|
24
|
+
}}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Block A: compact list ↔ wide 3-column dashboard with different card heights */
|
|
30
|
+
function BlockA({ expanded }: { expanded: boolean }) {
|
|
31
|
+
if (!expanded) {
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
style={{
|
|
35
|
+
padding: "14px 18px",
|
|
36
|
+
borderRadius: 12,
|
|
37
|
+
background: "rgba(255,255,255,0.03)",
|
|
38
|
+
borderLeft: `3px solid ${BLOCKS[0].color}`,
|
|
39
|
+
transition: "min-height 0.35s ease",
|
|
40
|
+
minHeight: 72,
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<span
|
|
44
|
+
style={{
|
|
45
|
+
fontSize: 11,
|
|
46
|
+
fontWeight: 700,
|
|
47
|
+
color: BLOCKS[0].color,
|
|
48
|
+
letterSpacing: "0.08em",
|
|
49
|
+
textTransform: "uppercase",
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
{BLOCKS[0].label} — compact
|
|
53
|
+
</span>
|
|
54
|
+
<p
|
|
55
|
+
style={{
|
|
56
|
+
margin: "8px 0 0",
|
|
57
|
+
fontSize: 12,
|
|
58
|
+
color: "rgba(255,255,255,0.5)",
|
|
59
|
+
lineHeight: 1.5,
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
Single column. Low vertical footprint.
|
|
63
|
+
</p>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div
|
|
70
|
+
style={{
|
|
71
|
+
padding: 16,
|
|
72
|
+
borderRadius: 12,
|
|
73
|
+
background: "rgba(102, 126, 234, 0.06)",
|
|
74
|
+
border: `1px solid ${BLOCKS[0].color}33`,
|
|
75
|
+
transition: "min-height 0.35s ease",
|
|
76
|
+
minHeight: 200,
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<div
|
|
80
|
+
style={{
|
|
81
|
+
fontSize: 11,
|
|
82
|
+
fontWeight: 700,
|
|
83
|
+
color: BLOCKS[0].color,
|
|
84
|
+
letterSpacing: "0.08em",
|
|
85
|
+
textTransform: "uppercase",
|
|
86
|
+
marginBottom: 12,
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
{BLOCKS[0].label} — grid layout
|
|
90
|
+
</div>
|
|
91
|
+
<div
|
|
92
|
+
style={{
|
|
93
|
+
display: "grid",
|
|
94
|
+
gridTemplateColumns: "repeat(3, 1fr)",
|
|
95
|
+
gap: 10,
|
|
96
|
+
alignItems: "start",
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
<div
|
|
100
|
+
style={{
|
|
101
|
+
padding: 12,
|
|
102
|
+
borderRadius: 8,
|
|
103
|
+
background: "rgba(0,0,0,0.25)",
|
|
104
|
+
minHeight: 100,
|
|
105
|
+
border: "1px solid rgba(255,255,255,0.06)",
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
<div
|
|
109
|
+
style={{
|
|
110
|
+
height: 40,
|
|
111
|
+
borderRadius: 6,
|
|
112
|
+
background: `linear-gradient(90deg, ${BLOCKS[0].color}44, transparent)`,
|
|
113
|
+
marginBottom: 8,
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
116
|
+
<div style={{ fontSize: 10, color: "rgba(255,255,255,0.45)" }}>
|
|
117
|
+
Tall card
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
<div
|
|
121
|
+
style={{
|
|
122
|
+
padding: 12,
|
|
123
|
+
borderRadius: 8,
|
|
124
|
+
background: "rgba(0,0,0,0.25)",
|
|
125
|
+
minHeight: 52,
|
|
126
|
+
border: "1px solid rgba(255,255,255,0.06)",
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
<div style={{ fontSize: 10, color: "rgba(255,255,255,0.45)" }}>
|
|
130
|
+
Short
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
<div
|
|
134
|
+
style={{
|
|
135
|
+
padding: 12,
|
|
136
|
+
borderRadius: 8,
|
|
137
|
+
background: "rgba(0,0,0,0.25)",
|
|
138
|
+
minHeight: 140,
|
|
139
|
+
border: "1px solid rgba(255,255,255,0.06)",
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<div
|
|
143
|
+
style={{
|
|
144
|
+
display: "flex",
|
|
145
|
+
flexDirection: "column",
|
|
146
|
+
gap: 6,
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
{[1, 2, 3].map((n) => (
|
|
150
|
+
<div
|
|
151
|
+
key={n}
|
|
152
|
+
style={{
|
|
153
|
+
height: 8,
|
|
154
|
+
borderRadius: 4,
|
|
155
|
+
background: "rgba(255,255,255,0.08)",
|
|
156
|
+
width: `${60 + n * 12}%`,
|
|
157
|
+
}}
|
|
158
|
+
/>
|
|
159
|
+
))}
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Block B: sidebar + main ↔ stacked hero + stat strip + two columns */
|
|
168
|
+
function BlockB({ expanded }: { expanded: boolean }) {
|
|
169
|
+
if (!expanded) {
|
|
170
|
+
return (
|
|
171
|
+
<div
|
|
172
|
+
style={{
|
|
173
|
+
display: "flex",
|
|
174
|
+
gap: 14,
|
|
175
|
+
padding: 16,
|
|
176
|
+
borderRadius: 12,
|
|
177
|
+
background: "rgba(255,255,255,0.03)",
|
|
178
|
+
borderLeft: `3px solid ${BLOCKS[1].color}`,
|
|
179
|
+
minHeight: 120,
|
|
180
|
+
transition: "all 0.35s ease",
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
<aside
|
|
184
|
+
style={{
|
|
185
|
+
width: 88,
|
|
186
|
+
flexShrink: 0,
|
|
187
|
+
borderRadius: 8,
|
|
188
|
+
background: "rgba(240, 147, 251, 0.12)",
|
|
189
|
+
border: "1px solid rgba(240, 147, 251, 0.25)",
|
|
190
|
+
}}
|
|
191
|
+
/>
|
|
192
|
+
<div style={{ flex: 1, minWidth: 0 }}>
|
|
193
|
+
<span
|
|
194
|
+
style={{
|
|
195
|
+
fontSize: 11,
|
|
196
|
+
fontWeight: 700,
|
|
197
|
+
color: BLOCKS[1].color,
|
|
198
|
+
letterSpacing: "0.08em",
|
|
199
|
+
textTransform: "uppercase",
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
{BLOCKS[1].label} — sidebar
|
|
203
|
+
</span>
|
|
204
|
+
<p
|
|
205
|
+
style={{
|
|
206
|
+
margin: "8px 0 0",
|
|
207
|
+
fontSize: 12,
|
|
208
|
+
color: "rgba(255,255,255,0.5)",
|
|
209
|
+
lineHeight: 1.55,
|
|
210
|
+
}}
|
|
211
|
+
>
|
|
212
|
+
Horizontal split: narrow rail + fluid main. Pan/zoom should stay put
|
|
213
|
+
when this flips to a tall stacked layout.
|
|
214
|
+
</p>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<div
|
|
222
|
+
style={{
|
|
223
|
+
padding: 16,
|
|
224
|
+
borderRadius: 12,
|
|
225
|
+
background: "rgba(240, 147, 251, 0.07)",
|
|
226
|
+
border: `1px solid ${BLOCKS[1].color}33`,
|
|
227
|
+
minHeight: 320,
|
|
228
|
+
transition: "all 0.35s ease",
|
|
229
|
+
}}
|
|
230
|
+
>
|
|
231
|
+
<div
|
|
232
|
+
style={{
|
|
233
|
+
height: 72,
|
|
234
|
+
borderRadius: 10,
|
|
235
|
+
marginBottom: 12,
|
|
236
|
+
background: `linear-gradient(135deg, ${BLOCKS[1].color}55, rgba(15,15,26,0.9))`,
|
|
237
|
+
display: "flex",
|
|
238
|
+
alignItems: "center",
|
|
239
|
+
padding: "0 16px",
|
|
240
|
+
}}
|
|
241
|
+
>
|
|
242
|
+
<span
|
|
243
|
+
style={{
|
|
244
|
+
fontSize: 14,
|
|
245
|
+
fontWeight: 800,
|
|
246
|
+
color: "#fff",
|
|
247
|
+
letterSpacing: "-0.02em",
|
|
248
|
+
}}
|
|
249
|
+
>
|
|
250
|
+
{BLOCKS[1].label} — hero band
|
|
251
|
+
</span>
|
|
252
|
+
</div>
|
|
253
|
+
<div
|
|
254
|
+
style={{
|
|
255
|
+
display: "flex",
|
|
256
|
+
gap: 8,
|
|
257
|
+
marginBottom: 14,
|
|
258
|
+
}}
|
|
259
|
+
>
|
|
260
|
+
{["24%", "1.2k", "98"].map((v, i) => (
|
|
261
|
+
<div
|
|
262
|
+
key={v}
|
|
263
|
+
style={{
|
|
264
|
+
flex: 1,
|
|
265
|
+
padding: "10px 8px",
|
|
266
|
+
borderRadius: 8,
|
|
267
|
+
background: "rgba(0,0,0,0.28)",
|
|
268
|
+
textAlign: "center",
|
|
269
|
+
border: "1px solid rgba(255,255,255,0.06)",
|
|
270
|
+
}}
|
|
271
|
+
>
|
|
272
|
+
<div
|
|
273
|
+
style={{
|
|
274
|
+
fontSize: 16,
|
|
275
|
+
fontWeight: 800,
|
|
276
|
+
color: BLOCKS[1].color,
|
|
277
|
+
}}
|
|
278
|
+
>
|
|
279
|
+
{v}
|
|
280
|
+
</div>
|
|
281
|
+
<div
|
|
282
|
+
style={{
|
|
283
|
+
fontSize: 9,
|
|
284
|
+
color: "rgba(255,255,255,0.35)",
|
|
285
|
+
textTransform: "uppercase",
|
|
286
|
+
letterSpacing: "0.06em",
|
|
287
|
+
}}
|
|
288
|
+
>
|
|
289
|
+
{["Load", "Views", "Score"][i]}
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
))}
|
|
293
|
+
</div>
|
|
294
|
+
<div
|
|
295
|
+
style={{
|
|
296
|
+
display: "grid",
|
|
297
|
+
gridTemplateColumns: "1fr 1fr",
|
|
298
|
+
gap: 10,
|
|
299
|
+
}}
|
|
300
|
+
>
|
|
301
|
+
<div
|
|
302
|
+
style={{
|
|
303
|
+
padding: 12,
|
|
304
|
+
borderRadius: 8,
|
|
305
|
+
background: "rgba(0,0,0,0.22)",
|
|
306
|
+
minHeight: 110,
|
|
307
|
+
border: "1px solid rgba(255,255,255,0.05)",
|
|
308
|
+
}}
|
|
309
|
+
>
|
|
310
|
+
<div
|
|
311
|
+
style={{
|
|
312
|
+
fontSize: 10,
|
|
313
|
+
color: "rgba(255,255,255,0.35)",
|
|
314
|
+
marginBottom: 8,
|
|
315
|
+
}}
|
|
316
|
+
>
|
|
317
|
+
Left column
|
|
318
|
+
</div>
|
|
319
|
+
<div
|
|
320
|
+
style={{
|
|
321
|
+
height: 64,
|
|
322
|
+
borderRadius: 6,
|
|
323
|
+
background:
|
|
324
|
+
"repeating-linear-gradient(-45deg, rgba(255,255,255,0.04), rgba(255,255,255,0.04) 4px, transparent 4px, transparent 8px)",
|
|
325
|
+
}}
|
|
326
|
+
/>
|
|
327
|
+
</div>
|
|
328
|
+
<div
|
|
329
|
+
style={{
|
|
330
|
+
padding: 12,
|
|
331
|
+
borderRadius: 8,
|
|
332
|
+
background: "rgba(0,0,0,0.22)",
|
|
333
|
+
minHeight: 110,
|
|
334
|
+
border: "1px solid rgba(255,255,255,0.05)",
|
|
335
|
+
}}
|
|
336
|
+
>
|
|
337
|
+
<div
|
|
338
|
+
style={{
|
|
339
|
+
fontSize: 10,
|
|
340
|
+
color: "rgba(255,255,255,0.35)",
|
|
341
|
+
marginBottom: 8,
|
|
342
|
+
}}
|
|
343
|
+
>
|
|
344
|
+
Right column
|
|
345
|
+
</div>
|
|
346
|
+
{[40, 55, 35, 70].map((w) => (
|
|
347
|
+
<div
|
|
348
|
+
key={w}
|
|
349
|
+
style={{
|
|
350
|
+
height: 10,
|
|
351
|
+
marginBottom: 6,
|
|
352
|
+
borderRadius: 4,
|
|
353
|
+
background: "rgba(255,255,255,0.07)",
|
|
354
|
+
width: `${w}%`,
|
|
355
|
+
}}
|
|
356
|
+
/>
|
|
357
|
+
))}
|
|
358
|
+
</div>
|
|
359
|
+
</div>
|
|
360
|
+
</div>
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** Block C: minimal ↔ long scrollable-style stack (gallery + list + footer) */
|
|
365
|
+
function BlockC({ expanded }: { expanded: boolean }) {
|
|
366
|
+
if (!expanded) {
|
|
367
|
+
return (
|
|
368
|
+
<div
|
|
369
|
+
style={{
|
|
370
|
+
padding: "12px 16px",
|
|
371
|
+
borderRadius: 12,
|
|
372
|
+
background: "rgba(255,255,255,0.03)",
|
|
373
|
+
borderLeft: `3px solid ${BLOCKS[2].color}`,
|
|
374
|
+
minHeight: 56,
|
|
375
|
+
transition: "all 0.35s ease",
|
|
376
|
+
}}
|
|
377
|
+
>
|
|
378
|
+
<span
|
|
379
|
+
style={{
|
|
380
|
+
fontSize: 11,
|
|
381
|
+
fontWeight: 700,
|
|
382
|
+
color: BLOCKS[2].color,
|
|
383
|
+
letterSpacing: "0.08em",
|
|
384
|
+
textTransform: "uppercase",
|
|
385
|
+
}}
|
|
386
|
+
>
|
|
387
|
+
{BLOCKS[2].label} — minimal
|
|
388
|
+
</span>
|
|
389
|
+
</div>
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return (
|
|
394
|
+
<div
|
|
395
|
+
style={{
|
|
396
|
+
padding: 16,
|
|
397
|
+
borderRadius: 12,
|
|
398
|
+
background: "rgba(67, 233, 123, 0.06)",
|
|
399
|
+
border: `1px solid ${BLOCKS[2].color}33`,
|
|
400
|
+
minHeight: 380,
|
|
401
|
+
transition: "all 0.35s ease",
|
|
402
|
+
}}
|
|
403
|
+
>
|
|
404
|
+
<div
|
|
405
|
+
style={{
|
|
406
|
+
fontSize: 11,
|
|
407
|
+
fontWeight: 700,
|
|
408
|
+
color: BLOCKS[2].color,
|
|
409
|
+
letterSpacing: "0.08em",
|
|
410
|
+
textTransform: "uppercase",
|
|
411
|
+
marginBottom: 12,
|
|
412
|
+
}}
|
|
413
|
+
>
|
|
414
|
+
{BLOCKS[2].label} — expanded stack
|
|
415
|
+
</div>
|
|
416
|
+
<div
|
|
417
|
+
style={{
|
|
418
|
+
display: "flex",
|
|
419
|
+
gap: 8,
|
|
420
|
+
marginBottom: 14,
|
|
421
|
+
overflow: "hidden",
|
|
422
|
+
}}
|
|
423
|
+
>
|
|
424
|
+
{[0, 1, 2, 3, 4].map((i) => (
|
|
425
|
+
<div
|
|
426
|
+
key={i}
|
|
427
|
+
style={{
|
|
428
|
+
width: 56,
|
|
429
|
+
height: 56,
|
|
430
|
+
flexShrink: 0,
|
|
431
|
+
borderRadius: 8,
|
|
432
|
+
background: `linear-gradient(135deg, ${BLOCKS[2].color}${i % 2 ? "66" : "33"}, rgba(0,0,0,0.4))`,
|
|
433
|
+
border: "1px solid rgba(255,255,255,0.08)",
|
|
434
|
+
}}
|
|
435
|
+
/>
|
|
436
|
+
))}
|
|
437
|
+
</div>
|
|
438
|
+
<div
|
|
439
|
+
style={{
|
|
440
|
+
display: "flex",
|
|
441
|
+
flexDirection: "column",
|
|
442
|
+
gap: 8,
|
|
443
|
+
marginBottom: 14,
|
|
444
|
+
}}
|
|
445
|
+
>
|
|
446
|
+
{["Item alpha", "Item beta", "Item gamma", "Item delta"].map(
|
|
447
|
+
(label, i) => (
|
|
448
|
+
<div
|
|
449
|
+
key={label}
|
|
450
|
+
style={{
|
|
451
|
+
display: "flex",
|
|
452
|
+
alignItems: "center",
|
|
453
|
+
gap: 10,
|
|
454
|
+
padding: "10px 12px",
|
|
455
|
+
borderRadius: 8,
|
|
456
|
+
background: "rgba(0,0,0,0.22)",
|
|
457
|
+
border: "1px solid rgba(255,255,255,0.05)",
|
|
458
|
+
}}
|
|
459
|
+
>
|
|
460
|
+
<div
|
|
461
|
+
style={{
|
|
462
|
+
width: 28,
|
|
463
|
+
height: 28,
|
|
464
|
+
borderRadius: 6,
|
|
465
|
+
background: `rgba(67, 233, 123, ${0.15 + i * 0.08})`,
|
|
466
|
+
}}
|
|
467
|
+
/>
|
|
468
|
+
<div style={{ flex: 1 }}>
|
|
469
|
+
<div
|
|
470
|
+
style={{
|
|
471
|
+
fontSize: 12,
|
|
472
|
+
fontWeight: 600,
|
|
473
|
+
color: "rgba(255,255,255,0.75)",
|
|
474
|
+
}}
|
|
475
|
+
>
|
|
476
|
+
{label}
|
|
477
|
+
</div>
|
|
478
|
+
<div
|
|
479
|
+
style={{
|
|
480
|
+
fontSize: 10,
|
|
481
|
+
color: "rgba(255,255,255,0.35)",
|
|
482
|
+
marginTop: 2,
|
|
483
|
+
}}
|
|
484
|
+
>
|
|
485
|
+
Extra rows push total content height way up — good stress for
|
|
486
|
+
layout reflow under zoom.
|
|
487
|
+
</div>
|
|
488
|
+
</div>
|
|
489
|
+
</div>
|
|
490
|
+
),
|
|
491
|
+
)}
|
|
492
|
+
</div>
|
|
493
|
+
<div
|
|
494
|
+
style={{
|
|
495
|
+
padding: "12px 14px",
|
|
496
|
+
borderRadius: 8,
|
|
497
|
+
background: "rgba(0,0,0,0.35)",
|
|
498
|
+
borderTop: `2px solid ${BLOCKS[2].color}44`,
|
|
499
|
+
fontSize: 11,
|
|
500
|
+
color: "rgba(255,255,255,0.45)",
|
|
501
|
+
lineHeight: 1.5,
|
|
502
|
+
}}
|
|
503
|
+
>
|
|
504
|
+
Footer strip appears only in expanded mode, adding another vertical
|
|
505
|
+
block. Together, A/B/C expansions reshape the canvas dramatically while
|
|
506
|
+
the transform state should remain stable.
|
|
507
|
+
</div>
|
|
508
|
+
</div>
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export const Example: React.FC<any> = (args: any) => {
|
|
513
|
+
const [toggles, setToggles] = useState([false, false, false]);
|
|
514
|
+
|
|
515
|
+
useEffect(() => {
|
|
516
|
+
const timers = BLOCKS.map((block, i) =>
|
|
517
|
+
setInterval(() => {
|
|
518
|
+
setToggles((prev) => {
|
|
519
|
+
const next = [...prev];
|
|
520
|
+
next[i] = !next[i];
|
|
521
|
+
return next;
|
|
522
|
+
});
|
|
523
|
+
}, block.interval),
|
|
524
|
+
);
|
|
525
|
+
return () => timers.forEach(clearInterval);
|
|
526
|
+
}, []);
|
|
527
|
+
|
|
528
|
+
const [a, b, c] = toggles;
|
|
529
|
+
|
|
530
|
+
return (
|
|
531
|
+
<div style={{ fontFamily: "system-ui, -apple-system, sans-serif" }}>
|
|
532
|
+
<TransformWrapper {...normalizeArgs(args)} centerOnInit>
|
|
533
|
+
{(utils) => (
|
|
534
|
+
<div style={{ position: "relative" }}>
|
|
535
|
+
<Controls {...utils} position="bottom-left" />
|
|
536
|
+
<TransformComponent
|
|
537
|
+
wrapperStyle={{
|
|
538
|
+
...viewerFrame,
|
|
539
|
+
background:
|
|
540
|
+
"linear-gradient(145deg, #0c1029 0%, #111827 40%, #0a0f1e 100%)",
|
|
541
|
+
width: "500px",
|
|
542
|
+
height: "500px",
|
|
543
|
+
maxWidth: "80vw",
|
|
544
|
+
maxHeight: "75vh",
|
|
545
|
+
}}
|
|
546
|
+
contentStyle={{
|
|
547
|
+
width: "500px",
|
|
548
|
+
minHeight: 500,
|
|
549
|
+
}}
|
|
550
|
+
>
|
|
551
|
+
<div style={{ padding: 24 }}>
|
|
552
|
+
<div
|
|
553
|
+
style={{
|
|
554
|
+
display: "flex",
|
|
555
|
+
alignItems: "center",
|
|
556
|
+
gap: 16,
|
|
557
|
+
marginBottom: 20,
|
|
558
|
+
flexWrap: "wrap",
|
|
559
|
+
}}
|
|
560
|
+
>
|
|
561
|
+
<h2
|
|
562
|
+
style={{
|
|
563
|
+
margin: 0,
|
|
564
|
+
fontSize: 18,
|
|
565
|
+
fontWeight: 700,
|
|
566
|
+
color: "rgba(255,255,255,0.9)",
|
|
567
|
+
}}
|
|
568
|
+
>
|
|
569
|
+
Layout reflow
|
|
570
|
+
</h2>
|
|
571
|
+
<div
|
|
572
|
+
style={{ display: "flex", alignItems: "center", gap: 10 }}
|
|
573
|
+
>
|
|
574
|
+
{BLOCKS.map((block, i) => (
|
|
575
|
+
<div
|
|
576
|
+
key={block.label}
|
|
577
|
+
style={{
|
|
578
|
+
display: "flex",
|
|
579
|
+
alignItems: "center",
|
|
580
|
+
gap: 5,
|
|
581
|
+
}}
|
|
582
|
+
>
|
|
583
|
+
<StatusDot active={toggles[i]} color={block.color} />
|
|
584
|
+
<span
|
|
585
|
+
style={{
|
|
586
|
+
fontSize: 10,
|
|
587
|
+
color: "rgba(255,255,255,0.4)",
|
|
588
|
+
fontWeight: 600,
|
|
589
|
+
letterSpacing: "0.04em",
|
|
590
|
+
}}
|
|
591
|
+
>
|
|
592
|
+
{block.desc}
|
|
593
|
+
</span>
|
|
594
|
+
</div>
|
|
595
|
+
))}
|
|
596
|
+
</div>
|
|
597
|
+
</div>
|
|
598
|
+
|
|
599
|
+
<p
|
|
600
|
+
style={{
|
|
601
|
+
margin: "0 0 20px",
|
|
602
|
+
fontSize: 12,
|
|
603
|
+
lineHeight: 1.55,
|
|
604
|
+
color: "rgba(255,255,255,0.45)",
|
|
605
|
+
}}
|
|
606
|
+
>
|
|
607
|
+
Each block alternates between a <strong>compact</strong> and a{" "}
|
|
608
|
+
<strong>large</strong> layout: different grids, columns,
|
|
609
|
+
heights, and extra sections. This is a stronger test than text
|
|
610
|
+
swaps alone — pan and zoom should stay stable.
|
|
611
|
+
</p>
|
|
612
|
+
|
|
613
|
+
<div
|
|
614
|
+
style={{
|
|
615
|
+
display: "flex",
|
|
616
|
+
flexDirection: "column",
|
|
617
|
+
gap: 14,
|
|
618
|
+
}}
|
|
619
|
+
>
|
|
620
|
+
<BlockA expanded={a} />
|
|
621
|
+
<BlockB expanded={b} />
|
|
622
|
+
<BlockC expanded={c} />
|
|
623
|
+
</div>
|
|
624
|
+
</div>
|
|
625
|
+
</TransformComponent>
|
|
626
|
+
</div>
|
|
627
|
+
)}
|
|
628
|
+
</TransformWrapper>
|
|
629
|
+
</div>
|
|
630
|
+
);
|
|
631
|
+
};
|