react-zoom-pan-pinch 4.0.0 → 4.0.2
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/package.json +4 -3
- 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 +0 -1
- package/src/stories/assets/small-image.jpg +0 -0
- package/src/stories/assets/svg-example.svg +0 -14
- package/src/stories/docs/DocTable.tsx +0 -59
- package/src/stories/docs/HandlerCards.tsx +0 -102
- package/src/stories/docs/Introduction.stories.mdx +0 -135
- package/src/stories/docs/PropTable.tsx +0 -116
- package/src/stories/docs/docs.module.css +0 -370
- package/src/stories/docs/handlers.stories.mdx +0 -7
- package/src/stories/docs/handlers.tsx +0 -111
- package/src/stories/docs/props.stories.mdx +0 -11
- package/src/stories/docs/props.tsx +0 -571
- package/src/stories/examples/axis-lock/axis-lock.stories.mdx +0 -35
- package/src/stories/examples/axis-lock/example.tsx +0 -114
- package/src/stories/examples/bounds/bounds.data.tsx +0 -191
- package/src/stories/examples/bounds/bounds.stories.mdx +0 -99
- package/src/stories/examples/center-zoomed-out/center-zoomed-out.stories.mdx +0 -206
- package/src/stories/examples/cinema/cinema-data.tsx +0 -578
- package/src/stories/examples/cinema/cinema.stories.mdx +0 -30
- package/src/stories/examples/cinema/example.tsx +0 -378
- package/src/stories/examples/cinema/image.png +0 -0
- package/src/stories/examples/content/content.stories.mdx +0 -172
- package/src/stories/examples/content/mixed-content.data.tsx +0 -624
- package/src/stories/examples/content-rerendering/content-updating.stories.mdx +0 -34
- package/src/stories/examples/content-rerendering/example.tsx +0 -631
- package/src/stories/examples/controls/controls.stories.mdx +0 -120
- package/src/stories/examples/image/example.tsx +0 -149
- package/src/stories/examples/image/image.stories.mdx +0 -46
- package/src/stories/examples/image-annotations/example.tsx +0 -1442
- package/src/stories/examples/image-annotations/image-annotations.stories.mdx +0 -39
- package/src/stories/examples/image-responsive/example.tsx +0 -152
- package/src/stories/examples/image-responsive/image-responsive.stories.mdx +0 -51
- package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +0 -107
- package/src/stories/examples/initial-transform/example.tsx +0 -233
- package/src/stories/examples/initial-transform/initial-transform.stories.mdx +0 -37
- package/src/stories/examples/keep-scale/example.tsx +0 -882
- package/src/stories/examples/keep-scale/keep-scale.stories.mdx +0 -30
- package/src/stories/examples/keep-scale/map.stories.mdx +0 -28
- package/src/stories/examples/medical-viewer/chest-xray.tsx +0 -246
- package/src/stories/examples/medical-viewer/example.tsx +0 -690
- package/src/stories/examples/medical-viewer/medical-viewer.stories.mdx +0 -49
- package/src/stories/examples/mini-map/example.tsx +0 -122
- package/src/stories/examples/mini-map/mini-map.stories.mdx +0 -26
- package/src/stories/examples/miro/example.tsx +0 -1573
- package/src/stories/examples/miro/miro.stories.mdx +0 -31
- package/src/stories/examples/padding/example.tsx +0 -147
- package/src/stories/examples/padding/padding.stories.mdx +0 -35
- package/src/stories/examples/product-card/example.tsx +0 -594
- package/src/stories/examples/product-card/product-card.stories.mdx +0 -29
- package/src/stories/examples/stadium/example.tsx +0 -1040
- package/src/stories/examples/stadium/stadium-data.ts +0 -224
- package/src/stories/examples/stadium/stadium.stories.mdx +0 -32
- package/src/stories/examples/stress/example.tsx +0 -59
- package/src/stories/examples/stress/stress-test.stories.mdx +0 -28
- package/src/stories/examples/svg-zoom-to-element/creativity.svg +0 -143
- package/src/stories/examples/svg-zoom-to-element/example.tsx +0 -95
- package/src/stories/examples/svg-zoom-to-element/svg-zoom-to-element.stories.mdx +0 -28
- package/src/stories/examples/text-selection/example.tsx +0 -221
- package/src/stories/examples/text-selection/text-selection.stories.mdx +0 -31
- package/src/stories/examples/velocity/example.tsx +0 -908
- package/src/stories/examples/velocity/velocity.stories.mdx +0 -35
- package/src/stories/examples/virtualize/example.tsx +0 -239
- package/src/stories/examples/virtualize/virtualize.stories.mdx +0 -84
- package/src/stories/examples/zoom-to-element/example.tsx +0 -219
- package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +0 -31
- package/src/stories/hooks/use-controls.stories.mdx +0 -86
- package/src/stories/hooks/use-transform-component.stories.mdx +0 -108
- package/src/stories/hooks/use-transform-context.stories.mdx +0 -92
- package/src/stories/hooks/use-transform-effect.stories.mdx +0 -114
- package/src/stories/hooks/use-transform-init.stories.mdx +0 -105
- package/src/stories/types/args.types.ts +0 -192
- package/src/stories/utils/args.utils.ts +0 -35
- package/src/stories/utils/bounds-overlay.tsx +0 -168
- package/src/stories/utils/code.utils.tsx +0 -22
- package/src/stories/utils/controls.utils.tsx +0 -347
- package/src/stories/utils/index.ts +0 -5
- package/src/stories/utils/styles.module.css +0 -223
- package/src/stories/utils/viewer.styles.ts +0 -34
|
@@ -1,882 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useRef, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import { TransformComponent, TransformWrapper, KeepScale } from "components";
|
|
4
|
-
import { Controls, CloseIcon, normalizeArgs, viewerChrome } from "../../utils";
|
|
5
|
-
|
|
6
|
-
const font = 'Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif';
|
|
7
|
-
|
|
8
|
-
const CANVAS_W = 2400;
|
|
9
|
-
const CANVAS_H = 1600;
|
|
10
|
-
|
|
11
|
-
/* ── Location data ─────────────────────────────────────────── */
|
|
12
|
-
|
|
13
|
-
interface Location {
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
sub: string;
|
|
17
|
-
category: "landmark" | "nature" | "district" | "transport";
|
|
18
|
-
x: number;
|
|
19
|
-
y: number;
|
|
20
|
-
icon: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const CATEGORY_META: Record<
|
|
24
|
-
Location["category"],
|
|
25
|
-
{ accent: string; glow: string; label: string }
|
|
26
|
-
> = {
|
|
27
|
-
landmark: {
|
|
28
|
-
accent: "#f59e0b",
|
|
29
|
-
glow: "rgba(245,158,11,0.35)",
|
|
30
|
-
label: "Landmarks",
|
|
31
|
-
},
|
|
32
|
-
nature: { accent: "#10b981", glow: "rgba(16,185,129,0.35)", label: "Nature" },
|
|
33
|
-
district: {
|
|
34
|
-
accent: "#6366f1",
|
|
35
|
-
glow: "rgba(99,102,241,0.35)",
|
|
36
|
-
label: "Districts",
|
|
37
|
-
},
|
|
38
|
-
transport: {
|
|
39
|
-
accent: "#06b6d4",
|
|
40
|
-
glow: "rgba(6,182,212,0.35)",
|
|
41
|
-
label: "Transport",
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const LOCATIONS: Location[] = [
|
|
46
|
-
{
|
|
47
|
-
id: "loc-harbor",
|
|
48
|
-
name: "Harbor District",
|
|
49
|
-
sub: "Historic waterfront & marina",
|
|
50
|
-
category: "landmark",
|
|
51
|
-
icon: "⚓",
|
|
52
|
-
x: 380,
|
|
53
|
-
y: 920,
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
id: "loc-old-town",
|
|
57
|
-
name: "Old Town",
|
|
58
|
-
sub: "Medieval quarter, est. 1242",
|
|
59
|
-
category: "district",
|
|
60
|
-
icon: "🏛",
|
|
61
|
-
x: 820,
|
|
62
|
-
y: 580,
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
id: "loc-tech",
|
|
66
|
-
name: "Tech Campus",
|
|
67
|
-
sub: "Innovation hub & co-working",
|
|
68
|
-
category: "district",
|
|
69
|
-
icon: "💡",
|
|
70
|
-
x: 1560,
|
|
71
|
-
y: 420,
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
id: "loc-park",
|
|
75
|
-
name: "Emerald Park",
|
|
76
|
-
sub: "120 hectares of urban forest",
|
|
77
|
-
category: "nature",
|
|
78
|
-
icon: "🌿",
|
|
79
|
-
x: 1180,
|
|
80
|
-
y: 880,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
id: "loc-marina",
|
|
84
|
-
name: "Marina Bay",
|
|
85
|
-
sub: "Yacht club & seaside dining",
|
|
86
|
-
category: "landmark",
|
|
87
|
-
icon: "⛵",
|
|
88
|
-
x: 1940,
|
|
89
|
-
y: 1100,
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
id: "loc-station",
|
|
93
|
-
name: "Central Station",
|
|
94
|
-
sub: "Rail hub · 12 platforms",
|
|
95
|
-
category: "transport",
|
|
96
|
-
icon: "🚂",
|
|
97
|
-
x: 980,
|
|
98
|
-
y: 340,
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
id: "loc-bridge",
|
|
102
|
-
name: "Skyline Bridge",
|
|
103
|
-
sub: "Suspension bridge, 480m span",
|
|
104
|
-
category: "landmark",
|
|
105
|
-
icon: "🌉",
|
|
106
|
-
x: 600,
|
|
107
|
-
y: 1200,
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
id: "loc-gardens",
|
|
111
|
-
name: "Botanical Gardens",
|
|
112
|
-
sub: "Tropical greenhouse & trails",
|
|
113
|
-
category: "nature",
|
|
114
|
-
icon: "🌺",
|
|
115
|
-
x: 1780,
|
|
116
|
-
y: 720,
|
|
117
|
-
},
|
|
118
|
-
];
|
|
119
|
-
|
|
120
|
-
/* ── Procedural map (SVG + CSS) ────────────────────────────── */
|
|
121
|
-
|
|
122
|
-
const IslandMap = React.memo(function IslandMap() {
|
|
123
|
-
return (
|
|
124
|
-
<div
|
|
125
|
-
style={{
|
|
126
|
-
position: "relative",
|
|
127
|
-
width: CANVAS_W,
|
|
128
|
-
height: CANVAS_H,
|
|
129
|
-
background:
|
|
130
|
-
"linear-gradient(170deg, #1a3a5c 0%, #1e4d6e 30%, #1a3a5c 60%, #142d4a 100%)",
|
|
131
|
-
overflow: "hidden",
|
|
132
|
-
}}
|
|
133
|
-
>
|
|
134
|
-
{/* Water texture */}
|
|
135
|
-
<div
|
|
136
|
-
style={{
|
|
137
|
-
position: "absolute",
|
|
138
|
-
inset: 0,
|
|
139
|
-
backgroundImage: [
|
|
140
|
-
"radial-gradient(ellipse 600px 400px at 15% 85%, rgba(6,182,212,0.08) 0%, transparent 70%)",
|
|
141
|
-
"radial-gradient(ellipse 500px 300px at 85% 20%, rgba(56,189,248,0.06) 0%, transparent 70%)",
|
|
142
|
-
"radial-gradient(ellipse 800px 500px at 50% 50%, rgba(14,165,233,0.04) 0%, transparent 70%)",
|
|
143
|
-
].join(", "),
|
|
144
|
-
pointerEvents: "none",
|
|
145
|
-
}}
|
|
146
|
-
/>
|
|
147
|
-
|
|
148
|
-
<svg
|
|
149
|
-
width={CANVAS_W}
|
|
150
|
-
height={CANVAS_H}
|
|
151
|
-
style={{ position: "absolute", inset: 0 }}
|
|
152
|
-
aria-hidden
|
|
153
|
-
>
|
|
154
|
-
<defs>
|
|
155
|
-
<linearGradient id="land-main" x1="0" y1="0" x2="1" y2="1">
|
|
156
|
-
<stop offset="0%" stopColor="#2d5a3d" />
|
|
157
|
-
<stop offset="50%" stopColor="#3a6b4a" />
|
|
158
|
-
<stop offset="100%" stopColor="#2a5038" />
|
|
159
|
-
</linearGradient>
|
|
160
|
-
<linearGradient id="land-south" x1="0" y1="0" x2="0.5" y2="1">
|
|
161
|
-
<stop offset="0%" stopColor="#35654a" />
|
|
162
|
-
<stop offset="100%" stopColor="#2a5038" />
|
|
163
|
-
</linearGradient>
|
|
164
|
-
<linearGradient id="land-east" x1="0" y1="0" x2="1" y2="0.5">
|
|
165
|
-
<stop offset="0%" stopColor="#3a6b4a" />
|
|
166
|
-
<stop offset="100%" stopColor="#2d5a3d" />
|
|
167
|
-
</linearGradient>
|
|
168
|
-
<filter id="land-shadow">
|
|
169
|
-
<feDropShadow
|
|
170
|
-
dx="0"
|
|
171
|
-
dy="4"
|
|
172
|
-
stdDeviation="12"
|
|
173
|
-
floodColor="#0a1628"
|
|
174
|
-
floodOpacity="0.5"
|
|
175
|
-
/>
|
|
176
|
-
</filter>
|
|
177
|
-
<filter id="soft-glow">
|
|
178
|
-
<feGaussianBlur stdDeviation="3" />
|
|
179
|
-
</filter>
|
|
180
|
-
</defs>
|
|
181
|
-
|
|
182
|
-
{/* Main island */}
|
|
183
|
-
<path
|
|
184
|
-
d="M 300 500 C 320 380, 500 280, 700 260 C 900 240, 1100 220, 1300 280
|
|
185
|
-
C 1500 340, 1700 300, 1900 380 C 2050 440, 2100 560, 2080 700
|
|
186
|
-
C 2060 840, 1980 960, 1860 1040 C 1740 1120, 1560 1160, 1380 1140
|
|
187
|
-
C 1200 1120, 1040 1080, 900 1060 C 760 1040, 600 1080, 460 1020
|
|
188
|
-
C 320 960, 260 820, 280 680 C 290 580, 290 540, 300 500 Z"
|
|
189
|
-
fill="url(#land-main)"
|
|
190
|
-
filter="url(#land-shadow)"
|
|
191
|
-
/>
|
|
192
|
-
|
|
193
|
-
{/* Southern peninsula */}
|
|
194
|
-
<path
|
|
195
|
-
d="M 460 1020 C 500 1060, 540 1160, 520 1260
|
|
196
|
-
C 500 1340, 560 1380, 660 1360
|
|
197
|
-
C 760 1340, 820 1260, 800 1180
|
|
198
|
-
C 780 1120, 840 1080, 900 1060"
|
|
199
|
-
fill="url(#land-south)"
|
|
200
|
-
filter="url(#land-shadow)"
|
|
201
|
-
/>
|
|
202
|
-
|
|
203
|
-
{/* Eastern island */}
|
|
204
|
-
<path
|
|
205
|
-
d="M 1860 1040 C 1920 1080, 2000 1060, 2080 1100
|
|
206
|
-
C 2160 1140, 2200 1220, 2160 1300
|
|
207
|
-
C 2120 1380, 2020 1380, 1940 1340
|
|
208
|
-
C 1860 1300, 1820 1220, 1840 1140
|
|
209
|
-
C 1850 1100, 1850 1060, 1860 1040 Z"
|
|
210
|
-
fill="url(#land-east)"
|
|
211
|
-
filter="url(#land-shadow)"
|
|
212
|
-
/>
|
|
213
|
-
|
|
214
|
-
{/* Beach / coastline highlights */}
|
|
215
|
-
<path
|
|
216
|
-
d="M 300 500 C 320 380, 500 280, 700 260 C 900 240, 1100 220, 1300 280
|
|
217
|
-
C 1500 340, 1700 300, 1900 380 C 2050 440, 2100 560, 2080 700"
|
|
218
|
-
fill="none"
|
|
219
|
-
stroke="rgba(250, 235, 200, 0.12)"
|
|
220
|
-
strokeWidth="4"
|
|
221
|
-
/>
|
|
222
|
-
|
|
223
|
-
{/* Mountain range */}
|
|
224
|
-
<g opacity="0.35">
|
|
225
|
-
<polygon points="900,360 940,280 980,360" fill="#4a7a5a" />
|
|
226
|
-
<polygon points="960,370 1010,270 1060,370" fill="#3d6a4a" />
|
|
227
|
-
<polygon points="1040,360 1080,260 1120,360" fill="#4a7a5a" />
|
|
228
|
-
<polygon points="1100,370 1150,290 1200,370" fill="#3d6a4a" />
|
|
229
|
-
{/* Snow caps */}
|
|
230
|
-
<polygon
|
|
231
|
-
points="930,300 940,280 950,300"
|
|
232
|
-
fill="rgba(255,255,255,0.5)"
|
|
233
|
-
/>
|
|
234
|
-
<polygon
|
|
235
|
-
points="1000,290 1010,270 1020,290"
|
|
236
|
-
fill="rgba(255,255,255,0.5)"
|
|
237
|
-
/>
|
|
238
|
-
<polygon
|
|
239
|
-
points="1070,280 1080,260 1090,280"
|
|
240
|
-
fill="rgba(255,255,255,0.5)"
|
|
241
|
-
/>
|
|
242
|
-
<polygon
|
|
243
|
-
points="1140,310 1150,290 1160,310"
|
|
244
|
-
fill="rgba(255,255,255,0.5)"
|
|
245
|
-
/>
|
|
246
|
-
</g>
|
|
247
|
-
|
|
248
|
-
{/* Park / forest area */}
|
|
249
|
-
<ellipse
|
|
250
|
-
cx="1180"
|
|
251
|
-
cy="880"
|
|
252
|
-
rx="160"
|
|
253
|
-
ry="120"
|
|
254
|
-
fill="rgba(34,197,94,0.15)"
|
|
255
|
-
/>
|
|
256
|
-
{Array.from({ length: 18 }, (_, i) => {
|
|
257
|
-
const angle = (i / 18) * Math.PI * 2;
|
|
258
|
-
const r = 60 + (i % 3) * 30;
|
|
259
|
-
return (
|
|
260
|
-
<circle
|
|
261
|
-
key={i}
|
|
262
|
-
cx={1180 + Math.cos(angle) * r}
|
|
263
|
-
cy={880 + Math.sin(angle) * r * 0.75}
|
|
264
|
-
r={8 + (i % 4) * 3}
|
|
265
|
-
fill={`rgba(34, 197, 94, ${0.15 + (i % 3) * 0.05})`}
|
|
266
|
-
/>
|
|
267
|
-
);
|
|
268
|
-
})}
|
|
269
|
-
|
|
270
|
-
{/* Roads */}
|
|
271
|
-
<g
|
|
272
|
-
stroke="rgba(255,255,255,0.1)"
|
|
273
|
-
strokeWidth="3"
|
|
274
|
-
fill="none"
|
|
275
|
-
strokeLinecap="round"
|
|
276
|
-
>
|
|
277
|
-
<path d="M 380 920 C 500 860, 650 700, 820 580" />
|
|
278
|
-
<path d="M 820 580 L 980 340" />
|
|
279
|
-
<path d="M 820 580 C 1000 550, 1300 430, 1560 420" />
|
|
280
|
-
<path d="M 980 340 C 1100 380, 1300 400, 1560 420" />
|
|
281
|
-
<path d="M 1560 420 C 1680 520, 1750 640, 1780 720" />
|
|
282
|
-
<path d="M 1180 880 C 1400 900, 1600 940, 1780 720" />
|
|
283
|
-
<path d="M 1180 880 C 1400 960, 1700 1020, 1940 1100" />
|
|
284
|
-
<path d="M 380 920 C 450 1000, 520 1100, 600 1200" />
|
|
285
|
-
<path d="M 820 580 C 900 720, 1000 800, 1180 880" />
|
|
286
|
-
</g>
|
|
287
|
-
|
|
288
|
-
{/* Road dots (intersections) */}
|
|
289
|
-
{[
|
|
290
|
-
[820, 580],
|
|
291
|
-
[980, 340],
|
|
292
|
-
[1560, 420],
|
|
293
|
-
[1180, 880],
|
|
294
|
-
[1780, 720],
|
|
295
|
-
].map(([cx, cy]) => (
|
|
296
|
-
<circle
|
|
297
|
-
key={`${cx}-${cy}`}
|
|
298
|
-
cx={cx}
|
|
299
|
-
cy={cy}
|
|
300
|
-
r={4}
|
|
301
|
-
fill="rgba(255,255,255,0.12)"
|
|
302
|
-
/>
|
|
303
|
-
))}
|
|
304
|
-
|
|
305
|
-
{/* Water ripples */}
|
|
306
|
-
{[
|
|
307
|
-
[180, 300, 80],
|
|
308
|
-
[2300, 500, 60],
|
|
309
|
-
[200, 1300, 70],
|
|
310
|
-
[2200, 1400, 50],
|
|
311
|
-
[1400, 1400, 90],
|
|
312
|
-
].map(([cx, cy, r]) => (
|
|
313
|
-
<g key={`${cx}-${cy}-${r}`} opacity="0.06">
|
|
314
|
-
<circle
|
|
315
|
-
cx={cx}
|
|
316
|
-
cy={cy}
|
|
317
|
-
r={r}
|
|
318
|
-
fill="none"
|
|
319
|
-
stroke="#38bdf8"
|
|
320
|
-
strokeWidth="1"
|
|
321
|
-
/>
|
|
322
|
-
<circle
|
|
323
|
-
cx={cx}
|
|
324
|
-
cy={cy}
|
|
325
|
-
r={r * 0.6}
|
|
326
|
-
fill="none"
|
|
327
|
-
stroke="#38bdf8"
|
|
328
|
-
strokeWidth="0.8"
|
|
329
|
-
/>
|
|
330
|
-
</g>
|
|
331
|
-
))}
|
|
332
|
-
|
|
333
|
-
{/* Compass rose */}
|
|
334
|
-
<g transform="translate(160, 160)" opacity="0.2">
|
|
335
|
-
<circle
|
|
336
|
-
cx="0"
|
|
337
|
-
cy="0"
|
|
338
|
-
r="32"
|
|
339
|
-
fill="none"
|
|
340
|
-
stroke="rgba(255,255,255,0.3)"
|
|
341
|
-
strokeWidth="1"
|
|
342
|
-
/>
|
|
343
|
-
<line
|
|
344
|
-
x1="0"
|
|
345
|
-
y1="-28"
|
|
346
|
-
x2="0"
|
|
347
|
-
y2="28"
|
|
348
|
-
stroke="rgba(255,255,255,0.25)"
|
|
349
|
-
strokeWidth="1"
|
|
350
|
-
/>
|
|
351
|
-
<line
|
|
352
|
-
x1="-28"
|
|
353
|
-
y1="0"
|
|
354
|
-
x2="28"
|
|
355
|
-
y2="0"
|
|
356
|
-
stroke="rgba(255,255,255,0.25)"
|
|
357
|
-
strokeWidth="1"
|
|
358
|
-
/>
|
|
359
|
-
<polygon points="0,-26 -4,-10 4,-10" fill="rgba(248,113,113,0.6)" />
|
|
360
|
-
<polygon points="0,26 -4,10 4,10" fill="rgba(255,255,255,0.15)" />
|
|
361
|
-
<text
|
|
362
|
-
x="0"
|
|
363
|
-
y="-36"
|
|
364
|
-
textAnchor="middle"
|
|
365
|
-
fill="rgba(255,255,255,0.35)"
|
|
366
|
-
fontSize="10"
|
|
367
|
-
fontWeight="700"
|
|
368
|
-
fontFamily={font}
|
|
369
|
-
>
|
|
370
|
-
N
|
|
371
|
-
</text>
|
|
372
|
-
</g>
|
|
373
|
-
|
|
374
|
-
{/* Scale bar */}
|
|
375
|
-
<g transform="translate(2100, 1500)" opacity="0.2">
|
|
376
|
-
<line
|
|
377
|
-
x1="0"
|
|
378
|
-
y1="0"
|
|
379
|
-
x2="120"
|
|
380
|
-
y2="0"
|
|
381
|
-
stroke="rgba(255,255,255,0.4)"
|
|
382
|
-
strokeWidth="1.5"
|
|
383
|
-
/>
|
|
384
|
-
<line
|
|
385
|
-
x1="0"
|
|
386
|
-
y1="-4"
|
|
387
|
-
x2="0"
|
|
388
|
-
y2="4"
|
|
389
|
-
stroke="rgba(255,255,255,0.4)"
|
|
390
|
-
strokeWidth="1"
|
|
391
|
-
/>
|
|
392
|
-
<line
|
|
393
|
-
x1="120"
|
|
394
|
-
y1="-4"
|
|
395
|
-
x2="120"
|
|
396
|
-
y2="4"
|
|
397
|
-
stroke="rgba(255,255,255,0.4)"
|
|
398
|
-
strokeWidth="1"
|
|
399
|
-
/>
|
|
400
|
-
<text
|
|
401
|
-
x="60"
|
|
402
|
-
y="14"
|
|
403
|
-
textAnchor="middle"
|
|
404
|
-
fill="rgba(255,255,255,0.3)"
|
|
405
|
-
fontSize="9"
|
|
406
|
-
fontFamily={font}
|
|
407
|
-
>
|
|
408
|
-
1 km
|
|
409
|
-
</text>
|
|
410
|
-
</g>
|
|
411
|
-
</svg>
|
|
412
|
-
|
|
413
|
-
{/* Building clusters (CSS) */}
|
|
414
|
-
{[
|
|
415
|
-
{ x: 780, y: 540, w: 80, h: 60 },
|
|
416
|
-
{ x: 1520, y: 380, w: 100, h: 70 },
|
|
417
|
-
{ x: 350, y: 880, w: 70, h: 50 },
|
|
418
|
-
{ x: 1900, y: 1060, w: 80, h: 60 },
|
|
419
|
-
].map((b) => (
|
|
420
|
-
<div
|
|
421
|
-
key={`${b.x}-${b.y}`}
|
|
422
|
-
style={{
|
|
423
|
-
position: "absolute",
|
|
424
|
-
left: b.x,
|
|
425
|
-
top: b.y,
|
|
426
|
-
width: b.w,
|
|
427
|
-
height: b.h,
|
|
428
|
-
borderRadius: 4,
|
|
429
|
-
background: "rgba(255,255,255,0.03)",
|
|
430
|
-
border: "1px solid rgba(255,255,255,0.04)",
|
|
431
|
-
}}
|
|
432
|
-
/>
|
|
433
|
-
))}
|
|
434
|
-
</div>
|
|
435
|
-
);
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
/* ── Map marker (KeepScale) ────────────────────────────────── */
|
|
439
|
-
|
|
440
|
-
function MapMarker(props: {
|
|
441
|
-
loc: Location;
|
|
442
|
-
selected: boolean;
|
|
443
|
-
onClick: () => void;
|
|
444
|
-
}) {
|
|
445
|
-
const { loc, selected, onClick } = props;
|
|
446
|
-
const meta = CATEGORY_META[loc.category];
|
|
447
|
-
|
|
448
|
-
return (
|
|
449
|
-
<div
|
|
450
|
-
style={{
|
|
451
|
-
position: "absolute",
|
|
452
|
-
left: loc.x,
|
|
453
|
-
top: loc.y,
|
|
454
|
-
zIndex: selected ? 10 : 2,
|
|
455
|
-
transform: "translate(-50%, -100%)",
|
|
456
|
-
}}
|
|
457
|
-
>
|
|
458
|
-
<KeepScale>
|
|
459
|
-
<button
|
|
460
|
-
type="button"
|
|
461
|
-
id={loc.id}
|
|
462
|
-
onClick={onClick}
|
|
463
|
-
style={{
|
|
464
|
-
display: "flex",
|
|
465
|
-
flexDirection: "column",
|
|
466
|
-
alignItems: "center",
|
|
467
|
-
gap: 2,
|
|
468
|
-
cursor: "pointer",
|
|
469
|
-
border: "none",
|
|
470
|
-
background: "transparent",
|
|
471
|
-
padding: 0,
|
|
472
|
-
fontFamily: font,
|
|
473
|
-
}}
|
|
474
|
-
>
|
|
475
|
-
{/* Pin body */}
|
|
476
|
-
<div
|
|
477
|
-
style={{
|
|
478
|
-
width: 38,
|
|
479
|
-
height: 38,
|
|
480
|
-
borderRadius: "50% 50% 50% 0",
|
|
481
|
-
transform: "rotate(-45deg)",
|
|
482
|
-
background: selected
|
|
483
|
-
? `linear-gradient(135deg, ${meta.accent}, ${meta.accent}cc)`
|
|
484
|
-
: `linear-gradient(135deg, ${meta.accent}cc, ${meta.accent}88)`,
|
|
485
|
-
boxShadow: selected
|
|
486
|
-
? `0 0 20px ${meta.glow}, 0 4px 16px rgba(0,0,0,0.4)`
|
|
487
|
-
: `0 2px 8px rgba(0,0,0,0.4)`,
|
|
488
|
-
border: selected
|
|
489
|
-
? "2px solid rgba(255,255,255,0.5)"
|
|
490
|
-
: "2px solid rgba(255,255,255,0.2)",
|
|
491
|
-
display: "flex",
|
|
492
|
-
alignItems: "center",
|
|
493
|
-
justifyContent: "center",
|
|
494
|
-
transition: "box-shadow 0.2s, border-color 0.2s",
|
|
495
|
-
}}
|
|
496
|
-
>
|
|
497
|
-
<span
|
|
498
|
-
style={{
|
|
499
|
-
transform: "rotate(45deg)",
|
|
500
|
-
fontSize: 16,
|
|
501
|
-
lineHeight: 1,
|
|
502
|
-
}}
|
|
503
|
-
>
|
|
504
|
-
{loc.icon}
|
|
505
|
-
</span>
|
|
506
|
-
</div>
|
|
507
|
-
|
|
508
|
-
{/* Label */}
|
|
509
|
-
<div
|
|
510
|
-
style={{
|
|
511
|
-
marginTop: 4,
|
|
512
|
-
padding: "3px 8px",
|
|
513
|
-
borderRadius: 6,
|
|
514
|
-
background: selected ? "rgba(0,0,0,0.85)" : "rgba(0,0,0,0.65)",
|
|
515
|
-
backdropFilter: "blur(6px)",
|
|
516
|
-
border: selected
|
|
517
|
-
? `1px solid ${meta.accent}66`
|
|
518
|
-
: "1px solid rgba(255,255,255,0.08)",
|
|
519
|
-
whiteSpace: "nowrap",
|
|
520
|
-
}}
|
|
521
|
-
>
|
|
522
|
-
<span
|
|
523
|
-
style={{
|
|
524
|
-
fontSize: 10,
|
|
525
|
-
fontWeight: 700,
|
|
526
|
-
color: selected ? meta.accent : "rgba(255,255,255,0.85)",
|
|
527
|
-
letterSpacing: "0.02em",
|
|
528
|
-
}}
|
|
529
|
-
>
|
|
530
|
-
{loc.name}
|
|
531
|
-
</span>
|
|
532
|
-
</div>
|
|
533
|
-
</button>
|
|
534
|
-
</KeepScale>
|
|
535
|
-
</div>
|
|
536
|
-
);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
/* ── Location bar (bottom panel) ───────────────────────────── */
|
|
540
|
-
|
|
541
|
-
function LocationBar(props: {
|
|
542
|
-
selectedId: string | null;
|
|
543
|
-
onSelect: (loc: Location) => void;
|
|
544
|
-
onReset: () => void;
|
|
545
|
-
}) {
|
|
546
|
-
const { selectedId, onSelect, onReset } = props;
|
|
547
|
-
const categories = Object.entries(CATEGORY_META) as [
|
|
548
|
-
Location["category"],
|
|
549
|
-
(typeof CATEGORY_META)[Location["category"]],
|
|
550
|
-
][];
|
|
551
|
-
|
|
552
|
-
return (
|
|
553
|
-
<div
|
|
554
|
-
style={{
|
|
555
|
-
marginTop: 14,
|
|
556
|
-
borderRadius: 14,
|
|
557
|
-
background: "rgba(10, 10, 20, 0.75)",
|
|
558
|
-
border: "1px solid rgba(255,255,255,0.06)",
|
|
559
|
-
backdropFilter: "blur(12px)",
|
|
560
|
-
padding: "14px 16px",
|
|
561
|
-
fontFamily: font,
|
|
562
|
-
}}
|
|
563
|
-
>
|
|
564
|
-
{/* Header */}
|
|
565
|
-
<div
|
|
566
|
-
style={{
|
|
567
|
-
display: "flex",
|
|
568
|
-
alignItems: "center",
|
|
569
|
-
justifyContent: "space-between",
|
|
570
|
-
marginBottom: 12,
|
|
571
|
-
}}
|
|
572
|
-
>
|
|
573
|
-
<div style={{ display: "flex", alignItems: "center", gap: 8 }}>
|
|
574
|
-
<span
|
|
575
|
-
style={{
|
|
576
|
-
fontSize: 12,
|
|
577
|
-
fontWeight: 700,
|
|
578
|
-
color: "rgba(255,255,255,0.6)",
|
|
579
|
-
letterSpacing: "0.06em",
|
|
580
|
-
textTransform: "uppercase",
|
|
581
|
-
}}
|
|
582
|
-
>
|
|
583
|
-
Locations
|
|
584
|
-
</span>
|
|
585
|
-
<span
|
|
586
|
-
style={{
|
|
587
|
-
fontSize: 10,
|
|
588
|
-
color: "rgba(255,255,255,0.3)",
|
|
589
|
-
padding: "2px 8px",
|
|
590
|
-
borderRadius: 6,
|
|
591
|
-
background: "rgba(255,255,255,0.04)",
|
|
592
|
-
}}
|
|
593
|
-
>
|
|
594
|
-
{LOCATIONS.length} points
|
|
595
|
-
</span>
|
|
596
|
-
</div>
|
|
597
|
-
<div style={{ display: "flex", gap: 12, alignItems: "center" }}>
|
|
598
|
-
{categories.map(([key, meta]) => (
|
|
599
|
-
<span
|
|
600
|
-
key={key}
|
|
601
|
-
style={{
|
|
602
|
-
display: "flex",
|
|
603
|
-
alignItems: "center",
|
|
604
|
-
gap: 5,
|
|
605
|
-
fontSize: 10,
|
|
606
|
-
fontWeight: 600,
|
|
607
|
-
color: "rgba(255,255,255,0.4)",
|
|
608
|
-
}}
|
|
609
|
-
>
|
|
610
|
-
<span
|
|
611
|
-
style={{
|
|
612
|
-
width: 7,
|
|
613
|
-
height: 7,
|
|
614
|
-
borderRadius: "50%",
|
|
615
|
-
background: meta.accent,
|
|
616
|
-
flexShrink: 0,
|
|
617
|
-
}}
|
|
618
|
-
/>
|
|
619
|
-
{meta.label}
|
|
620
|
-
</span>
|
|
621
|
-
))}
|
|
622
|
-
</div>
|
|
623
|
-
</div>
|
|
624
|
-
|
|
625
|
-
{/* Cards grid */}
|
|
626
|
-
<div
|
|
627
|
-
style={{
|
|
628
|
-
display: "grid",
|
|
629
|
-
gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))",
|
|
630
|
-
gap: 8,
|
|
631
|
-
}}
|
|
632
|
-
>
|
|
633
|
-
{LOCATIONS.map((loc) => {
|
|
634
|
-
const meta = CATEGORY_META[loc.category];
|
|
635
|
-
const sel = selectedId === loc.id;
|
|
636
|
-
return (
|
|
637
|
-
<button
|
|
638
|
-
key={loc.id}
|
|
639
|
-
type="button"
|
|
640
|
-
onClick={() => onSelect(loc)}
|
|
641
|
-
style={{
|
|
642
|
-
display: "flex",
|
|
643
|
-
alignItems: "center",
|
|
644
|
-
gap: 10,
|
|
645
|
-
padding: "10px 12px",
|
|
646
|
-
borderRadius: 10,
|
|
647
|
-
border: sel
|
|
648
|
-
? `1px solid ${meta.accent}55`
|
|
649
|
-
: "1px solid rgba(255,255,255,0.05)",
|
|
650
|
-
background: sel
|
|
651
|
-
? `linear-gradient(135deg, ${meta.accent}15, ${meta.accent}08)`
|
|
652
|
-
: "rgba(255,255,255,0.02)",
|
|
653
|
-
cursor: "pointer",
|
|
654
|
-
fontFamily: font,
|
|
655
|
-
textAlign: "left",
|
|
656
|
-
transition: "border-color 0.2s, background 0.2s",
|
|
657
|
-
}}
|
|
658
|
-
>
|
|
659
|
-
<span
|
|
660
|
-
style={{
|
|
661
|
-
width: 34,
|
|
662
|
-
height: 34,
|
|
663
|
-
borderRadius: 9,
|
|
664
|
-
background: sel
|
|
665
|
-
? `${meta.accent}25`
|
|
666
|
-
: "rgba(255,255,255,0.04)",
|
|
667
|
-
display: "flex",
|
|
668
|
-
alignItems: "center",
|
|
669
|
-
justifyContent: "center",
|
|
670
|
-
fontSize: 16,
|
|
671
|
-
flexShrink: 0,
|
|
672
|
-
border: sel
|
|
673
|
-
? `1px solid ${meta.accent}33`
|
|
674
|
-
: "1px solid rgba(255,255,255,0.04)",
|
|
675
|
-
}}
|
|
676
|
-
>
|
|
677
|
-
{loc.icon}
|
|
678
|
-
</span>
|
|
679
|
-
<div style={{ minWidth: 0 }}>
|
|
680
|
-
<div
|
|
681
|
-
style={{
|
|
682
|
-
fontSize: 12,
|
|
683
|
-
fontWeight: 700,
|
|
684
|
-
color: sel ? meta.accent : "rgba(255,255,255,0.85)",
|
|
685
|
-
lineHeight: 1.3,
|
|
686
|
-
overflow: "hidden",
|
|
687
|
-
textOverflow: "ellipsis",
|
|
688
|
-
whiteSpace: "nowrap",
|
|
689
|
-
}}
|
|
690
|
-
>
|
|
691
|
-
{loc.name}
|
|
692
|
-
</div>
|
|
693
|
-
<div
|
|
694
|
-
style={{
|
|
695
|
-
fontSize: 10,
|
|
696
|
-
color: "rgba(255,255,255,0.35)",
|
|
697
|
-
lineHeight: 1.4,
|
|
698
|
-
overflow: "hidden",
|
|
699
|
-
textOverflow: "ellipsis",
|
|
700
|
-
whiteSpace: "nowrap",
|
|
701
|
-
}}
|
|
702
|
-
>
|
|
703
|
-
{loc.sub}
|
|
704
|
-
</div>
|
|
705
|
-
</div>
|
|
706
|
-
</button>
|
|
707
|
-
);
|
|
708
|
-
})}
|
|
709
|
-
</div>
|
|
710
|
-
|
|
711
|
-
{selectedId && (
|
|
712
|
-
<div
|
|
713
|
-
style={{ marginTop: 10, display: "flex", justifyContent: "center" }}
|
|
714
|
-
>
|
|
715
|
-
<button
|
|
716
|
-
type="button"
|
|
717
|
-
onClick={onReset}
|
|
718
|
-
style={{
|
|
719
|
-
padding: "6px 20px",
|
|
720
|
-
borderRadius: 8,
|
|
721
|
-
border: "1px solid rgba(255,255,255,0.1)",
|
|
722
|
-
background: "rgba(255,255,255,0.04)",
|
|
723
|
-
color: "rgba(255,255,255,0.5)",
|
|
724
|
-
fontSize: 11,
|
|
725
|
-
fontWeight: 600,
|
|
726
|
-
cursor: "pointer",
|
|
727
|
-
fontFamily: font,
|
|
728
|
-
display: "flex",
|
|
729
|
-
alignItems: "center",
|
|
730
|
-
gap: 6,
|
|
731
|
-
}}
|
|
732
|
-
>
|
|
733
|
-
Reset view
|
|
734
|
-
</button>
|
|
735
|
-
</div>
|
|
736
|
-
)}
|
|
737
|
-
</div>
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
/* ── Selected badge ────────────────────────────────────────── */
|
|
742
|
-
|
|
743
|
-
function SelectedBadge({ loc }: { loc: Location | null }) {
|
|
744
|
-
if (!loc) return null;
|
|
745
|
-
const meta = CATEGORY_META[loc.category];
|
|
746
|
-
|
|
747
|
-
return (
|
|
748
|
-
<div
|
|
749
|
-
style={{
|
|
750
|
-
position: "absolute",
|
|
751
|
-
top: 14,
|
|
752
|
-
right: 14,
|
|
753
|
-
zIndex: 10,
|
|
754
|
-
padding: "8px 14px",
|
|
755
|
-
borderRadius: 10,
|
|
756
|
-
background: "rgba(6, 10, 24, 0.85)",
|
|
757
|
-
backdropFilter: "blur(12px)",
|
|
758
|
-
border: `1px solid ${meta.accent}44`,
|
|
759
|
-
display: "flex",
|
|
760
|
-
alignItems: "center",
|
|
761
|
-
gap: 10,
|
|
762
|
-
fontFamily: font,
|
|
763
|
-
maxWidth: 280,
|
|
764
|
-
}}
|
|
765
|
-
>
|
|
766
|
-
<span style={{ fontSize: 18 }}>{loc.icon}</span>
|
|
767
|
-
<div>
|
|
768
|
-
<div
|
|
769
|
-
style={{
|
|
770
|
-
fontSize: 13,
|
|
771
|
-
fontWeight: 700,
|
|
772
|
-
color: meta.accent,
|
|
773
|
-
lineHeight: 1.3,
|
|
774
|
-
}}
|
|
775
|
-
>
|
|
776
|
-
{loc.name}
|
|
777
|
-
</div>
|
|
778
|
-
<div
|
|
779
|
-
style={{
|
|
780
|
-
fontSize: 10,
|
|
781
|
-
color: "rgba(255,255,255,0.45)",
|
|
782
|
-
lineHeight: 1.4,
|
|
783
|
-
}}
|
|
784
|
-
>
|
|
785
|
-
{loc.sub}
|
|
786
|
-
</div>
|
|
787
|
-
</div>
|
|
788
|
-
</div>
|
|
789
|
-
);
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
/* ── Main ──────────────────────────────────────────────────── */
|
|
793
|
-
|
|
794
|
-
type Api = {
|
|
795
|
-
zoomToElement: (target: string | HTMLElement, scale?: number) => void;
|
|
796
|
-
resetTransform: () => void;
|
|
797
|
-
zoomIn: () => void;
|
|
798
|
-
zoomOut: () => void;
|
|
799
|
-
centerView: () => void;
|
|
800
|
-
};
|
|
801
|
-
|
|
802
|
-
export const Example: React.FC<any> = (args: any) => {
|
|
803
|
-
const [selected, setSelected] = useState<Location | null>(null);
|
|
804
|
-
const apiRef = useRef<Api | null>(null);
|
|
805
|
-
|
|
806
|
-
const handleSelect = useCallback((loc: Location) => {
|
|
807
|
-
setSelected(loc);
|
|
808
|
-
requestAnimationFrame(() => {
|
|
809
|
-
apiRef.current?.zoomToElement(loc.id, 4);
|
|
810
|
-
});
|
|
811
|
-
}, []);
|
|
812
|
-
|
|
813
|
-
const handleReset = useCallback(() => {
|
|
814
|
-
setSelected(null);
|
|
815
|
-
apiRef.current?.resetTransform();
|
|
816
|
-
}, []);
|
|
817
|
-
|
|
818
|
-
return (
|
|
819
|
-
<div style={{ fontFamily: font, maxWidth: 960 }}>
|
|
820
|
-
<TransformWrapper
|
|
821
|
-
{...normalizeArgs(args)}
|
|
822
|
-
initialScale={0.45}
|
|
823
|
-
minScale={0.3}
|
|
824
|
-
maxScale={100}
|
|
825
|
-
centerOnInit
|
|
826
|
-
centerZoomedOut
|
|
827
|
-
>
|
|
828
|
-
{(api) => {
|
|
829
|
-
apiRef.current = api;
|
|
830
|
-
return (
|
|
831
|
-
<>
|
|
832
|
-
<div style={{ position: "relative" }}>
|
|
833
|
-
<Controls
|
|
834
|
-
{...api}
|
|
835
|
-
extraButtons={
|
|
836
|
-
selected
|
|
837
|
-
? [
|
|
838
|
-
{
|
|
839
|
-
label: "Clear selection",
|
|
840
|
-
icon: <CloseIcon />,
|
|
841
|
-
onClick: handleReset,
|
|
842
|
-
},
|
|
843
|
-
]
|
|
844
|
-
: []
|
|
845
|
-
}
|
|
846
|
-
/>
|
|
847
|
-
<SelectedBadge loc={selected} />
|
|
848
|
-
<TransformComponent
|
|
849
|
-
wrapperStyle={{
|
|
850
|
-
...viewerChrome,
|
|
851
|
-
width: "100%",
|
|
852
|
-
height: "clamp(480px, calc(100vh - 360px), 680px)",
|
|
853
|
-
}}
|
|
854
|
-
contentStyle={{
|
|
855
|
-
width: CANVAS_W,
|
|
856
|
-
height: CANVAS_H,
|
|
857
|
-
}}
|
|
858
|
-
>
|
|
859
|
-
<IslandMap />
|
|
860
|
-
{LOCATIONS.map((loc) => (
|
|
861
|
-
<MapMarker
|
|
862
|
-
key={loc.id}
|
|
863
|
-
loc={loc}
|
|
864
|
-
selected={selected?.id === loc.id}
|
|
865
|
-
onClick={() => handleSelect(loc)}
|
|
866
|
-
/>
|
|
867
|
-
))}
|
|
868
|
-
</TransformComponent>
|
|
869
|
-
</div>
|
|
870
|
-
|
|
871
|
-
<LocationBar
|
|
872
|
-
selectedId={selected?.id ?? null}
|
|
873
|
-
onSelect={handleSelect}
|
|
874
|
-
onReset={handleReset}
|
|
875
|
-
/>
|
|
876
|
-
</>
|
|
877
|
-
);
|
|
878
|
-
}}
|
|
879
|
-
</TransformWrapper>
|
|
880
|
-
</div>
|
|
881
|
-
);
|
|
882
|
-
};
|