@deck.gl/widgets 9.3.0-alpha.6 → 9.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/compass-widget.d.ts +12 -0
  2. package/dist/compass-widget.d.ts.map +1 -1
  3. package/dist/compass-widget.js +9 -3
  4. package/dist/compass-widget.js.map +1 -1
  5. package/dist/dist.dev.js +205 -69
  6. package/dist/fullscreen-widget.d.ts +5 -0
  7. package/dist/fullscreen-widget.d.ts.map +1 -1
  8. package/dist/fullscreen-widget.js +18 -8
  9. package/dist/fullscreen-widget.js.map +1 -1
  10. package/dist/geocoder-widget.d.ts +13 -0
  11. package/dist/geocoder-widget.d.ts.map +1 -1
  12. package/dist/geocoder-widget.js +13 -1
  13. package/dist/geocoder-widget.js.map +1 -1
  14. package/dist/gimbal-widget.d.ts +12 -0
  15. package/dist/gimbal-widget.d.ts.map +1 -1
  16. package/dist/gimbal-widget.js +4 -1
  17. package/dist/gimbal-widget.js.map +1 -1
  18. package/dist/index.cjs +218 -70
  19. package/dist/index.cjs.map +2 -2
  20. package/dist/loading-widget.d.ts +5 -0
  21. package/dist/loading-widget.d.ts.map +1 -1
  22. package/dist/loading-widget.js +4 -1
  23. package/dist/loading-widget.js.map +1 -1
  24. package/dist/reset-view-widget.d.ts +9 -0
  25. package/dist/reset-view-widget.d.ts.map +1 -1
  26. package/dist/reset-view-widget.js +4 -1
  27. package/dist/reset-view-widget.js.map +1 -1
  28. package/dist/stats-widget.d.ts +18 -3
  29. package/dist/stats-widget.d.ts.map +1 -1
  30. package/dist/stats-widget.js +29 -12
  31. package/dist/stats-widget.js.map +1 -1
  32. package/dist/theme-widget.d.ts +20 -2
  33. package/dist/theme-widget.d.ts.map +1 -1
  34. package/dist/theme-widget.js +38 -14
  35. package/dist/theme-widget.js.map +1 -1
  36. package/dist/timeline-widget.d.ts +34 -3
  37. package/dist/timeline-widget.d.ts.map +1 -1
  38. package/dist/timeline-widget.js +98 -24
  39. package/dist/timeline-widget.js.map +1 -1
  40. package/dist/zoom-widget.d.ts +13 -1
  41. package/dist/zoom-widget.d.ts.map +1 -1
  42. package/dist/zoom-widget.js +7 -4
  43. package/dist/zoom-widget.js.map +1 -1
  44. package/dist.min.js +2 -2
  45. package/package.json +2 -2
  46. package/src/compass-widget.tsx +23 -3
  47. package/src/fullscreen-widget.tsx +24 -9
  48. package/src/geocoder-widget.tsx +23 -1
  49. package/src/gimbal-widget.tsx +17 -1
  50. package/src/loading-widget.tsx +11 -1
  51. package/src/reset-view-widget.tsx +15 -1
  52. package/src/stats-widget.tsx +42 -13
  53. package/src/theme-widget.tsx +56 -17
  54. package/src/timeline-widget.tsx +123 -24
  55. package/src/zoom-widget.tsx +20 -4
@@ -21,6 +21,18 @@ export type ZoomWidgetProps = WidgetProps & {
21
21
  zoomOutLabel?: string;
22
22
  /** Zoom transition duration in ms. 0 disables the transition */
23
23
  transitionDuration?: number;
24
+ /**
25
+ * Callback when zoom buttons are clicked.
26
+ * Called for each viewport that will be zoomed.
27
+ */
28
+ onZoom?: (params: {
29
+ /** The view being zoomed */
30
+ viewId: string;
31
+ /** Zoom direction: +1 for zoom in, -1 for zoom out */
32
+ delta: number;
33
+ /** The new zoom level */
34
+ zoom: number;
35
+ }) => void;
24
36
  };
25
37
 
26
38
  export class ZoomWidget extends Widget<ZoomWidgetProps> {
@@ -32,7 +44,8 @@ export class ZoomWidget extends Widget<ZoomWidgetProps> {
32
44
  transitionDuration: 200,
33
45
  zoomInLabel: 'Zoom In',
34
46
  zoomOutLabel: 'Zoom Out',
35
- viewId: null
47
+ viewId: null,
48
+ onZoom: () => {}
36
49
  };
37
50
 
38
51
  className = 'deck-widget-zoom';
@@ -67,7 +80,7 @@ export class ZoomWidget extends Widget<ZoomWidgetProps> {
67
80
  render(ui, rootElement);
68
81
  }
69
82
 
70
- handleZoom(viewId: string, nextZoom: number) {
83
+ handleZoom(viewId: string, nextZoom: number, delta: number) {
71
84
  // Respect minZoom/maxZoom constraints from the view state
72
85
  const viewState = this.getViewState(viewId);
73
86
  if (viewState) {
@@ -80,6 +93,9 @@ export class ZoomWidget extends Widget<ZoomWidgetProps> {
80
93
  }
81
94
  }
82
95
 
96
+ // Call callback
97
+ this.props.onZoom?.({viewId, delta, zoom: nextZoom});
98
+
83
99
  const nextViewState: Record<string, unknown> = {
84
100
  ...viewState,
85
101
  zoom: nextZoom
@@ -100,7 +116,7 @@ export class ZoomWidget extends Widget<ZoomWidgetProps> {
100
116
  const viewIds = this.viewId ? [this.viewId] : (this.deck?.getViews().map(v => v.id) ?? []);
101
117
  for (const viewId of viewIds) {
102
118
  const viewState = this.getViewState(viewId);
103
- this.handleZoom(viewId, (viewState.zoom as number) + 1);
119
+ this.handleZoom(viewId, (viewState.zoom as number) + 1, 1);
104
120
  }
105
121
  }
106
122
 
@@ -108,7 +124,7 @@ export class ZoomWidget extends Widget<ZoomWidgetProps> {
108
124
  const viewIds = this.viewId ? [this.viewId] : (this.deck?.getViews().map(v => v.id) ?? []);
109
125
  for (const viewId of viewIds) {
110
126
  const viewState = this.getViewState(viewId);
111
- this.handleZoom(viewId, (viewState.zoom as number) - 1);
127
+ this.handleZoom(viewId, (viewState.zoom as number) - 1, -1);
112
128
  }
113
129
  }
114
130
  }