@dxos/react-ui-geo 0.8.4-staging.ac66bdf99f → 0.9.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 (120) hide show
  1. package/LICENSE +102 -5
  2. package/data/countries-10m.ts +12 -0
  3. package/data/countries-110m.ts +4 -10579
  4. package/data/countries-50m.ts +12 -0
  5. package/dist/lib/browser/chunk-SC2FBYFU.mjs +17 -0
  6. package/dist/lib/browser/chunk-SC2FBYFU.mjs.map +7 -0
  7. package/dist/lib/browser/countries-10m-CWWDOKH7.mjs +6 -0
  8. package/dist/lib/browser/countries-10m-CWWDOKH7.mjs.map +7 -0
  9. package/dist/lib/browser/countries-110m-72QBAA5E.mjs +6 -0
  10. package/dist/lib/browser/countries-110m-72QBAA5E.mjs.map +7 -0
  11. package/dist/lib/browser/countries-50m-H7SL7KVF.mjs +6 -0
  12. package/dist/lib/browser/countries-50m-H7SL7KVF.mjs.map +7 -0
  13. package/dist/lib/browser/data.mjs +1 -1
  14. package/dist/lib/browser/index.mjs +774 -223
  15. package/dist/lib/browser/index.mjs.map +4 -4
  16. package/dist/lib/browser/meta.json +1 -1
  17. package/dist/lib/browser/translations.mjs +19 -0
  18. package/dist/lib/browser/translations.mjs.map +7 -0
  19. package/dist/lib/node-esm/chunk-VZENBYLJ.mjs +19 -0
  20. package/dist/lib/node-esm/chunk-VZENBYLJ.mjs.map +7 -0
  21. package/dist/lib/node-esm/countries-10m-DJZV66KG.mjs +8 -0
  22. package/dist/lib/node-esm/countries-10m-DJZV66KG.mjs.map +7 -0
  23. package/dist/lib/node-esm/countries-110m-H3WY6K4Q.mjs +8 -0
  24. package/dist/lib/node-esm/countries-110m-H3WY6K4Q.mjs.map +7 -0
  25. package/dist/lib/node-esm/countries-50m-ZY7Z3IWD.mjs +8 -0
  26. package/dist/lib/node-esm/countries-50m-ZY7Z3IWD.mjs.map +7 -0
  27. package/dist/lib/node-esm/data.mjs +1 -1
  28. package/dist/lib/node-esm/index.mjs +774 -223
  29. package/dist/lib/node-esm/index.mjs.map +4 -4
  30. package/dist/lib/node-esm/meta.json +1 -1
  31. package/dist/lib/node-esm/translations.mjs +21 -0
  32. package/dist/lib/node-esm/translations.mjs.map +7 -0
  33. package/dist/types/data/airports.d.ts +4 -4
  34. package/dist/types/data/airports.d.ts.map +1 -1
  35. package/dist/types/data/cities.d.ts.map +1 -1
  36. package/dist/types/data/countries-10m.d.ts +8 -0
  37. package/dist/types/data/countries-10m.d.ts.map +1 -0
  38. package/dist/types/data/countries-110m.d.ts +2 -30
  39. package/dist/types/data/countries-110m.d.ts.map +1 -1
  40. package/dist/types/data/countries-50m.d.ts +8 -0
  41. package/dist/types/data/countries-50m.d.ts.map +1 -0
  42. package/dist/types/data/countries-dots-3.d.ts.map +1 -1
  43. package/dist/types/data/countries-dots-4.d.ts.map +1 -1
  44. package/dist/types/src/components/Globe/Globe.d.ts +18 -10
  45. package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
  46. package/dist/types/src/components/Globe/Globe.stories.d.ts +16 -8
  47. package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
  48. package/dist/types/src/components/Map/Map.d.ts +49 -13
  49. package/dist/types/src/components/Map/Map.d.ts.map +1 -1
  50. package/dist/types/src/components/Map/Map.stories.d.ts +9 -5
  51. package/dist/types/src/components/Map/Map.stories.d.ts.map +1 -1
  52. package/dist/types/src/components/Toolbar/Controls.d.ts.map +1 -1
  53. package/dist/types/src/data.d.ts +9 -1
  54. package/dist/types/src/data.d.ts.map +1 -1
  55. package/dist/types/src/hooks/context.d.ts +37 -0
  56. package/dist/types/src/hooks/context.d.ts.map +1 -1
  57. package/dist/types/src/hooks/index.d.ts +3 -0
  58. package/dist/types/src/hooks/index.d.ts.map +1 -1
  59. package/dist/types/src/hooks/useDrag.d.ts +22 -2
  60. package/dist/types/src/hooks/useDrag.d.ts.map +1 -1
  61. package/dist/types/src/hooks/useGlobeZoomHandler.d.ts +3 -2
  62. package/dist/types/src/hooks/useGlobeZoomHandler.d.ts.map +1 -1
  63. package/dist/types/src/hooks/useMapZoomHandler.d.ts +1 -1
  64. package/dist/types/src/hooks/useMapZoomHandler.d.ts.map +1 -1
  65. package/dist/types/src/hooks/useSimplifiedTopology.d.ts +32 -0
  66. package/dist/types/src/hooks/useSimplifiedTopology.d.ts.map +1 -0
  67. package/dist/types/src/hooks/useSpinner.d.ts +1 -1
  68. package/dist/types/src/hooks/useSpinner.d.ts.map +1 -1
  69. package/dist/types/src/hooks/useTopology.d.ts +26 -0
  70. package/dist/types/src/hooks/useTopology.d.ts.map +1 -0
  71. package/dist/types/src/hooks/useTour.d.ts +3 -2
  72. package/dist/types/src/hooks/useTour.d.ts.map +1 -1
  73. package/dist/types/src/hooks/useWheel.d.ts +24 -0
  74. package/dist/types/src/hooks/useWheel.d.ts.map +1 -0
  75. package/dist/types/src/index.d.ts +0 -2
  76. package/dist/types/src/index.d.ts.map +1 -1
  77. package/dist/types/src/translations.d.ts +4 -4
  78. package/dist/types/src/translations.d.ts.map +1 -1
  79. package/dist/types/src/util/animation.d.ts +16 -0
  80. package/dist/types/src/util/animation.d.ts.map +1 -0
  81. package/dist/types/src/util/debug.d.ts.map +1 -1
  82. package/dist/types/src/util/index.d.ts +2 -0
  83. package/dist/types/src/util/index.d.ts.map +1 -1
  84. package/dist/types/src/util/inertia.d.ts.map +1 -1
  85. package/dist/types/src/util/path.d.ts.map +1 -1
  86. package/dist/types/src/util/render.d.ts +25 -1
  87. package/dist/types/src/util/render.d.ts.map +1 -1
  88. package/dist/types/src/util/styles.d.ts +4 -0
  89. package/dist/types/src/util/styles.d.ts.map +1 -0
  90. package/dist/types/tsconfig.tsbuildinfo +1 -1
  91. package/package.json +26 -24
  92. package/src/components/Globe/Globe.stories.tsx +135 -58
  93. package/src/components/Globe/Globe.tsx +237 -120
  94. package/src/components/Map/Map.stories.tsx +58 -12
  95. package/src/components/Map/Map.tsx +293 -91
  96. package/src/components/Toolbar/Controls.tsx +1 -1
  97. package/src/data.ts +19 -2
  98. package/src/hooks/context.tsx +44 -0
  99. package/src/hooks/index.ts +3 -0
  100. package/src/hooks/useDrag.ts +33 -5
  101. package/src/hooks/useGlobeZoomHandler.ts +2 -1
  102. package/src/hooks/useSimplifiedTopology.ts +81 -0
  103. package/src/hooks/useSpinner.ts +1 -1
  104. package/src/hooks/useTopology.ts +95 -0
  105. package/src/hooks/useTour.ts +70 -81
  106. package/src/hooks/useWheel.ts +83 -0
  107. package/src/index.ts +0 -2
  108. package/src/util/animation.ts +35 -0
  109. package/src/util/index.ts +2 -0
  110. package/src/util/inertia.ts +87 -4
  111. package/src/util/render.ts +105 -16
  112. package/src/util/styles.ts +62 -0
  113. package/dist/lib/browser/chunk-GMWLKTLN.mjs +0 -9
  114. package/dist/lib/browser/chunk-GMWLKTLN.mjs.map +0 -7
  115. package/dist/lib/browser/countries-110m-ZM3ZIEFS.mjs +0 -37859
  116. package/dist/lib/browser/countries-110m-ZM3ZIEFS.mjs.map +0 -7
  117. package/dist/lib/node-esm/chunk-JODBF4CC.mjs +0 -11
  118. package/dist/lib/node-esm/chunk-JODBF4CC.mjs.map +0 -7
  119. package/dist/lib/node-esm/countries-110m-3SFASWVD.mjs +0 -37861
  120. package/dist/lib/node-esm/countries-110m-3SFASWVD.mjs.map +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-geo",
3
- "version": "0.8.4-staging.ac66bdf99f",
3
+ "version": "0.9.0",
4
4
  "description": "Geo components.",
5
5
  "homepage": "https://github.com/dxos",
6
6
  "bugs": "https://github.com/dxos/issues",
@@ -8,32 +8,34 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/dxos/dxos"
10
10
  },
11
- "license": "MIT",
11
+ "license": "FSL-1.1-Apache-2.0",
12
12
  "author": "DXOS.org",
13
13
  "sideEffects": true,
14
14
  "type": "module",
15
+ "imports": {
16
+ "#translations": "./src/translations.ts"
17
+ },
15
18
  "exports": {
19
+ ".": {
20
+ "source": "./src/index.ts",
21
+ "types": "./dist/types/src/index.d.ts",
22
+ "browser": "./dist/lib/browser/index.mjs",
23
+ "node": "./dist/lib/node-esm/index.mjs"
24
+ },
16
25
  "./data": {
17
26
  "source": "./src/data.ts",
18
27
  "types": "./dist/types/src/data.d.ts",
19
28
  "browser": "./dist/lib/browser/data.mjs",
20
29
  "node": "./dist/lib/node-esm/data.mjs"
21
30
  },
22
- ".": {
23
- "source": "./src/index.ts",
24
- "types": "./dist/types/src/index.d.ts",
25
- "browser": "./dist/lib/browser/index.mjs",
26
- "node": "./dist/lib/node-esm/index.mjs"
31
+ "./translations": {
32
+ "source": "./src/translations.ts",
33
+ "types": "./dist/types/src/translations.d.ts",
34
+ "browser": "./dist/lib/browser/translations.mjs",
35
+ "node": "./dist/lib/node-esm/translations.mjs"
27
36
  }
28
37
  },
29
38
  "types": "dist/types/src/index.d.ts",
30
- "typesVersions": {
31
- "*": {
32
- "data": [
33
- "dist/types/src/data.d.ts"
34
- ]
35
- }
36
- },
37
39
  "files": [
38
40
  "data",
39
41
  "dist",
@@ -53,11 +55,11 @@
53
55
  "topojson-client": "^3.1.0",
54
56
  "topojson-simplify": "^3.0.3",
55
57
  "versor": "^0.2.0",
56
- "@dxos/log": "0.8.4-staging.ac66bdf99f",
57
- "@dxos/async": "0.8.4-staging.ac66bdf99f",
58
- "@dxos/debug": "0.8.4-staging.ac66bdf99f",
59
- "@dxos/node-std": "0.8.4-staging.ac66bdf99f",
60
- "@dxos/util": "0.8.4-staging.ac66bdf99f"
58
+ "@dxos/async": "0.9.0",
59
+ "@dxos/debug": "0.9.0",
60
+ "@dxos/node-std": "0.9.0",
61
+ "@dxos/log": "0.9.0",
62
+ "@dxos/util": "0.9.0"
61
63
  },
62
64
  "devDependencies": {
63
65
  "@react-three/drei": "^10.7.7",
@@ -77,15 +79,15 @@
77
79
  "react": "~19.2.3",
78
80
  "react-dom": "~19.2.3",
79
81
  "three": "^0.178.0",
80
- "@dxos/storybook-utils": "0.8.4-staging.ac66bdf99f",
81
- "@dxos/react-ui": "0.8.4-staging.ac66bdf99f",
82
- "@dxos/ui-theme": "0.8.4-staging.ac66bdf99f"
82
+ "@dxos/react-ui": "0.9.0",
83
+ "@dxos/storybook-utils": "0.9.0",
84
+ "@dxos/ui-theme": "0.9.0"
83
85
  },
84
86
  "peerDependencies": {
85
87
  "react": "~19.2.3",
86
88
  "react-dom": "~19.2.3",
87
- "@dxos/react-ui": "0.8.4-staging.ac66bdf99f",
88
- "@dxos/ui-theme": "0.8.4-staging.ac66bdf99f"
89
+ "@dxos/react-ui": "0.9.0",
90
+ "@dxos/ui-theme": "0.9.0"
89
91
  },
90
92
  "publishConfig": {
91
93
  "access": "public"
@@ -5,53 +5,54 @@
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import { type FeatureCollection, type Geometry, type Position } from 'geojson';
7
7
  import { Leva } from 'leva';
8
- import React, { useMemo, useRef, useState } from 'react';
8
+ import React, { useMemo, useState } from 'react';
9
9
  import { type Topology } from 'topojson-specification';
10
10
 
11
11
  import { useAsyncState } from '@dxos/react-ui';
12
12
  import { withLayout, withTheme } from '@dxos/react-ui/testing';
13
13
 
14
- import { type Vector, useDrag, useGlobeZoomHandler, useSpinner, useTour } from '../../hooks';
14
+ import { loadTopology } from '../../data';
15
+ import {
16
+ type GlobeController,
17
+ type Level,
18
+ type Vector,
19
+ useDrag,
20
+ useGlobeContext,
21
+ useGlobeZoomHandler,
22
+ useSpinner,
23
+ useTopology,
24
+ useTour,
25
+ useWheel,
26
+ } from '../../hooks';
15
27
  import { type LatLngLiteral } from '../../types';
16
28
  import { type StyleSet, closestPoint } from '../../util';
17
29
  import { type ControlProps } from '../Toolbar';
18
- import { Globe, type GlobeCanvasProps, type GlobeController, type GlobeRootProps } from './Globe';
19
-
20
- // TODO(burdon): Load from JSON at runtime?
21
- const useTopology = () => {
22
- return useAsyncState(async () => (await import('../../../data/countries-110m.ts')).default);
23
- };
30
+ import { Globe, type GlobeCanvasProps, type GlobeRootProps } from './Globe';
24
31
 
25
32
  const defaultStyles: StyleSet = {
26
33
  water: {
27
34
  fillStyle: '#0a0a0a',
28
35
  },
29
-
30
36
  land: {
31
37
  fillStyle: '#050505',
32
38
  strokeStyle: 'darkgreen',
33
39
  },
34
-
35
40
  graticule: {
36
41
  strokeStyle: '#111',
37
42
  },
38
-
39
43
  line: {
40
44
  lineWidth: 1,
41
45
  lineDash: [4, 16],
42
46
  strokeStyle: 'yellow',
43
47
  },
44
-
45
48
  point: {
46
49
  pointRadius: 2,
47
50
  fillStyle: 'red',
48
51
  },
49
-
50
52
  cursor: {
51
53
  fillStyle: 'orange',
52
54
  pointRadius: 2,
53
55
  },
54
-
55
56
  arc: {
56
57
  lineWidth: 2,
57
58
  strokeStyle: 'yellow',
@@ -63,17 +64,14 @@ const dotStyles: StyleSet = {
63
64
  fillStyle: '#444',
64
65
  pointRadius: 2,
65
66
  },
66
-
67
67
  point: {
68
68
  pointRadius: 2,
69
69
  fillStyle: 'red',
70
70
  },
71
-
72
71
  cursor: {
73
72
  fillStyle: 'orange',
74
73
  pointRadius: 2,
75
74
  },
76
-
77
75
  arc: {
78
76
  lineWidth: 2,
79
77
  strokeStyle: 'yellow',
@@ -132,7 +130,10 @@ type DefaultStoryProps = Pick<GlobeRootProps, 'zoom' | 'translation' | 'rotation
132
130
  drag?: boolean;
133
131
  spin?: boolean;
134
132
  tour?: boolean;
135
- xAxis?: boolean;
133
+ wheel?: boolean;
134
+ lockTilt?: boolean;
135
+ mode?: 'linear' | 'versor';
136
+ level?: Level;
136
137
  };
137
138
 
138
139
  const DefaultStory = ({
@@ -144,9 +145,12 @@ const DefaultStory = ({
144
145
  drag = false,
145
146
  spin = false,
146
147
  tour = false,
147
- xAxis = false,
148
+ wheel = false,
149
+ lockTilt = false,
150
+ mode,
151
+ level = '110m',
148
152
  }: DefaultStoryProps) => {
149
- const controller = useRef<GlobeController>(null);
153
+ const [controller, setController] = useState<GlobeController | null>(null);
150
154
  const [dots] = useAsyncState(async () => {
151
155
  const points = (await import('../../../data/countries-dots-3.ts')).default;
152
156
  return {
@@ -154,7 +158,7 @@ const DefaultStory = ({
154
158
  objects: { dots: points },
155
159
  } as any as Topology;
156
160
  });
157
- const [topology] = useTopology();
161
+ const [topology] = useAsyncState(() => loadTopology(level), [level]);
158
162
  const [airports] = useAsyncState(async () => (await import('../../../data/airports.ts')).default);
159
163
 
160
164
  const features = useMemo(() => {
@@ -162,10 +166,11 @@ const DefaultStory = ({
162
166
  }, [airports, routes, dots]);
163
167
 
164
168
  // Control hooks.
165
- const [startSpinner, stopSpinner] = useSpinner(controller.current, { disabled: !spin });
166
- const [_running, setRunning] = useTour(controller.current, features?.points, { disabled: !tour, styles });
167
- useDrag(controller.current, {
168
- xAxis,
169
+ const [startSpinner, stopSpinner] = useSpinner(controller, { disabled: !spin });
170
+ const [_running, setRunning] = useTour(controller, features?.points, { disabled: !tour, styles });
171
+ useDrag(controller, {
172
+ lockTilt,
173
+ mode,
169
174
  disabled: !drag,
170
175
  onUpdate: (event) => {
171
176
  switch (event.type) {
@@ -177,6 +182,13 @@ const DefaultStory = ({
177
182
  }
178
183
  },
179
184
  });
185
+ useWheel(controller, {
186
+ disabled: !wheel,
187
+ onUpdate: () => {
188
+ stopSpinner();
189
+ setRunning(false);
190
+ },
191
+ });
180
192
 
181
193
  // TODO(burdon): Factor out handlers.
182
194
  const handleAction: ControlProps['onAction'] = (event) => {
@@ -191,31 +203,32 @@ const DefaultStory = ({
191
203
  break;
192
204
  }
193
205
  case 'zoom-in': {
194
- controller.current.setZoom((scale) => scale * 1.1);
206
+ controller?.setZoom((scale) => scale * 1.1);
195
207
  break;
196
208
  }
197
209
  case 'zoom-out': {
198
- controller.current.setZoom((scale) => scale * 0.9);
210
+ controller?.setZoom((scale) => scale * 0.9);
199
211
  break;
200
212
  }
201
213
  }
202
214
  };
203
215
 
204
216
  return (
205
- <Globe.Root zoom={zoomProp} translation={translation} rotation={rotation}>
206
- <Globe.Canvas
207
- topology={styles?.dots ? dots : topology}
208
- projection={projection}
209
- styles={styles}
210
- features={tour ? { points: features?.points ?? [] } : features}
211
- ref={controller}
212
- />
213
- <Globe.Zoom onAction={handleAction} />
214
- <Globe.Action onAction={handleAction} />
215
- <Globe.Debug />
216
- <Globe.Panel position='topright' classNames='w-20 h-20'>
217
- <Leva />
218
- </Globe.Panel>
217
+ <Globe.Root zoom={zoomProp} translation={translation} rotation={rotation} ref={setController}>
218
+ <Globe.Viewport>
219
+ <Globe.Canvas
220
+ topology={styles?.dots ? dots : topology}
221
+ projection={projection}
222
+ styles={styles}
223
+ features={tour ? { points: features?.points ?? [] } : features}
224
+ />
225
+ <Globe.Zoom onAction={handleAction} />
226
+ <Globe.Action onAction={handleAction} />
227
+ <Globe.Debug />
228
+ <Globe.Panel position='topright' classNames='w-20 h-20'>
229
+ <Leva />
230
+ </Globe.Panel>
231
+ </Globe.Viewport>
219
232
  </Globe.Root>
220
233
  );
221
234
  };
@@ -234,31 +247,78 @@ const meta = {
234
247
 
235
248
  export default meta;
236
249
 
237
- export const Earth1 = () => {
238
- const [topology] = useTopology();
250
+ const Earth = ({ level }: { level: Level }) => {
251
+ const [topology] = useAsyncState(() => loadTopology(level), [level]);
239
252
  const [controller, setController] = useState<GlobeController | null>();
240
253
  const handleAction = useGlobeZoomHandler(controller);
241
254
  useDrag(controller);
255
+ useWheel(controller);
256
+
257
+ return (
258
+ <Globe.Root zoom={1.2} rotation={[0, 0, 0]} ref={setController}>
259
+ <Globe.Viewport>
260
+ <Globe.Canvas topology={topology} styles={defaultStyles} />
261
+ <Globe.Zoom onAction={handleAction} />
262
+ </Globe.Viewport>
263
+ </Globe.Root>
264
+ );
265
+ };
266
+
267
+ export const Topology110 = () => {
268
+ return <Earth level='110m' />;
269
+ };
270
+
271
+ export const Topology50 = () => {
272
+ return <Earth level='50m' />;
273
+ };
274
+
275
+ export const Topology10 = () => {
276
+ return <Earth level='10m' />;
277
+ };
242
278
 
279
+ /**
280
+ * Discrete-resolution LOD: swaps resolution by zoom via `useTopology(zoom)`. Each resolution is a
281
+ * code-split chunk fetched on demand the first time its tier is entered (default tiers: 110m / 50m).
282
+ * Reads the live zoom from the globe context, so it must render inside `Globe.Root`.
283
+ */
284
+ const DynamicCanvas = ({ controller }: { controller: GlobeController | null | undefined }) => {
285
+ const { zoom } = useGlobeContext();
286
+ const topology = useTopology(zoom);
287
+ const handleAction = useGlobeZoomHandler(controller);
288
+ useDrag(controller);
289
+ useWheel(controller);
243
290
  return (
244
- <Globe.Root zoom={1.2} rotation={[Math.random() * 360, 0, 0]}>
245
- <Globe.Canvas ref={setController} topology={topology} styles={defaultStyles} />
291
+ <Globe.Viewport>
292
+ <Globe.Canvas topology={topology} styles={defaultStyles} />
246
293
  <Globe.Zoom onAction={handleAction} />
294
+ <Globe.Debug />
295
+ </Globe.Viewport>
296
+ );
297
+ };
298
+
299
+ export const Dynamic = () => {
300
+ const [controller, setController] = useState<GlobeController | null>();
301
+ return (
302
+ <Globe.Root zoom={1.2} rotation={[0, 0, 0]} ref={setController}>
303
+ <DynamicCanvas controller={controller} />
247
304
  </Globe.Root>
248
305
  );
249
306
  };
250
307
 
251
- export const Earth2 = () => {
252
- const [topology] = useTopology();
308
+ export const Earthrise = () => {
309
+ const topology = useTopology();
253
310
  const [controller, setController] = useState<GlobeController | null>();
254
311
  const handleAction = useGlobeZoomHandler(controller);
255
312
  useDrag(controller);
313
+ useWheel(controller);
256
314
 
257
315
  return (
258
316
  <div className='absolute bottom-0 left-0 right-0 '>
259
- <Globe.Root classNames='h-[400px]' zoom={2.8} translation={{ x: 0, y: 400 }}>
260
- <Globe.Canvas ref={setController} topology={topology} styles={defaultStyles} />
261
- <Globe.Zoom onAction={handleAction} />
317
+ <Globe.Root zoom={2.8} translation={{ x: 0, y: 400 }} ref={setController}>
318
+ <Globe.Viewport classNames='h-[400px]'>
319
+ <Globe.Canvas topology={topology} styles={defaultStyles} />
320
+ <Globe.Zoom onAction={handleAction} />
321
+ </Globe.Viewport>
262
322
  </Globe.Root>
263
323
  </div>
264
324
  );
@@ -268,31 +328,31 @@ const monochrome: StyleSet = {
268
328
  water: {
269
329
  fillStyle: '#191919',
270
330
  },
271
-
272
331
  land: {
273
332
  fillStyle: '#444',
274
333
  strokeStyle: '#222',
275
334
  },
276
-
277
335
  border: {
278
336
  strokeStyle: '#111',
279
337
  },
280
-
281
338
  graticule: {
282
339
  strokeStyle: '#111',
283
340
  },
284
341
  };
285
342
 
286
343
  export const Mercator = () => {
287
- const [topology] = useTopology();
344
+ const topology = useTopology();
288
345
  const [controller, setController] = useState<GlobeController | null>();
289
346
  const handleAction = useGlobeZoomHandler(controller);
290
347
  useDrag(controller);
348
+ useWheel(controller);
291
349
 
292
350
  return (
293
- <Globe.Root classNames='flex grow overflow-hidden' zoom={0.7} rotation={initialRotation}>
294
- <Globe.Canvas ref={setController} topology={topology} projection='mercator' styles={monochrome} />
295
- <Globe.Zoom onAction={handleAction} />
351
+ <Globe.Root zoom={0.7} rotation={initialRotation} ref={setController}>
352
+ <Globe.Viewport>
353
+ <Globe.Canvas topology={topology} projection='mercator' styles={monochrome} />
354
+ <Globe.Zoom onAction={handleAction} />
355
+ </Globe.Viewport>
296
356
  </Globe.Root>
297
357
  );
298
358
  };
@@ -302,6 +362,7 @@ type Story = StoryObj<typeof DefaultStory>;
302
362
  export const Globe1: Story = {
303
363
  args: {
304
364
  drag: true,
365
+ wheel: true,
305
366
  projection: 'mercator',
306
367
  zoom: 0.8,
307
368
  rotation: initialRotation,
@@ -312,6 +373,7 @@ export const Globe1: Story = {
312
373
  export const Globe2: Story = {
313
374
  args: {
314
375
  drag: true,
376
+ wheel: true,
315
377
  projection: 'transverse-mercator',
316
378
  zoom: 0.8,
317
379
  rotation: initialRotation,
@@ -322,6 +384,7 @@ export const Globe2: Story = {
322
384
  export const Globe3: Story = {
323
385
  args: {
324
386
  drag: true,
387
+ wheel: true,
325
388
  spin: true,
326
389
  zoom: 1.5,
327
390
  rotation: initialRotation,
@@ -332,6 +395,7 @@ export const Globe3: Story = {
332
395
  export const Globe4: Story = {
333
396
  args: {
334
397
  drag: true,
398
+ wheel: true,
335
399
  tour: true,
336
400
  zoom: 2,
337
401
  rotation: initialRotation,
@@ -342,6 +406,7 @@ export const Globe4: Story = {
342
406
  export const Globe5: Story = {
343
407
  args: {
344
408
  drag: true,
409
+ wheel: true,
345
410
  tour: true,
346
411
  zoom: 0.9,
347
412
  rotation: initialRotation,
@@ -352,7 +417,8 @@ export const Globe5: Story = {
352
417
  export const Globe6: Story = {
353
418
  args: {
354
419
  drag: true,
355
- xAxis: true,
420
+ wheel: true,
421
+ lockTilt: true,
356
422
  tour: true,
357
423
  zoom: 2,
358
424
  translation: { x: 0, y: 600 },
@@ -360,3 +426,14 @@ export const Globe6: Story = {
360
426
  styles: dotStyles,
361
427
  },
362
428
  };
429
+
430
+ export const VersorDrag: Story = {
431
+ args: {
432
+ drag: true,
433
+ wheel: true,
434
+ mode: 'versor',
435
+ zoom: 1.5,
436
+ rotation: initialRotation,
437
+ styles: defaultStyles,
438
+ },
439
+ };