* Attach resize observer with RAF coalescing
( container: HTMLElement, chart: ChartGPUInstance )
| 79 | * Attach resize observer with RAF coalescing |
| 80 | */ |
| 81 | function attachResizeObserver( |
| 82 | container: HTMLElement, |
| 83 | chart: ChartGPUInstance |
| 84 | ): ResizeObserver { |
| 85 | let scheduled = false; |
| 86 | const ro = new ResizeObserver(() => { |
| 87 | if (scheduled) return; |
| 88 | scheduled = true; |
| 89 | requestAnimationFrame(() => { |
| 90 | scheduled = false; |
| 91 | chart.resize(); |
| 92 | }); |
| 93 | }); |
| 94 | ro.observe(container); |
| 95 | return ro; |
| 96 | } |
| 97 | |
| 98 | async function main(): Promise<void> { |
| 99 | const container1 = document.getElementById('chart1'); |