|
1 | 1 | /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ |
2 | 2 | /* eslint-disable no-underscore-dangle */ |
3 | | -import { BaseType, select } from 'd3-selection'; |
| 3 | +import { BaseType, select, Selection } from 'd3-selection'; |
4 | 4 | import { min } from 'd3-array'; |
5 | 5 | import type { Scatterplot } from './scatterplot'; |
6 | 6 | import type { Tile } from './tile'; |
@@ -123,7 +123,7 @@ class RenderProps { |
123 | 123 | export class Renderer { |
124 | 124 | // A renderer handles drawing to a display element. |
125 | 125 | public scatterplot: Scatterplot; |
126 | | - public holder: d3.Selection<Element, unknown, BaseType, unknown>; |
| 126 | + public holder: Selection<Element, unknown, BaseType, unknown>; |
127 | 127 | public canvas: HTMLCanvasElement; |
128 | 128 | public deeptable: Deeptable; |
129 | 129 | public width: number; |
@@ -264,6 +264,21 @@ export class Renderer { |
264 | 264 | return this; |
265 | 265 | } |
266 | 266 |
|
| 267 | + async wait_for_zoom_attachment() { |
| 268 | + let t = 0; |
| 269 | + const timeout = 2; // milliseconds. |
| 270 | + while (this._zoom === undefined) { |
| 271 | + await new Promise<void>((resolve) => { |
| 272 | + setTimeout(() => resolve(), timeout) |
| 273 | + }) |
| 274 | + t += timeout |
| 275 | + if (t > 1000) { |
| 276 | + console.warn('after 1 second, still no zoom state; this is likely a bug'); |
| 277 | + t = 0; |
| 278 | + } |
| 279 | + } |
| 280 | + } |
| 281 | + |
267 | 282 | async initialize() { |
268 | 283 | // Asynchronously wait for the basic elements to be done. |
269 | 284 | // await this._initializations; |
|
0 commit comments