|
9 | 9 | ref, |
10 | 10 | shallowRef, |
11 | 11 | toRefs, |
12 | | - watch, |
13 | | - watchEffect, |
| 12 | + watch, |
14 | 13 | } from "vue"; |
15 | 14 | import { |
16 | 15 | adaptColorToBackground, |
@@ -43,6 +42,7 @@ import { useTableResponsive } from "../useTableResponsive"; |
43 | 42 | import { useUserOptionState } from "../useUserOptionState"; |
44 | 43 | import { useTimeLabelCollision } from "../useTimeLabelCollider"; |
45 | 44 | import { useChartAccessibility } from "../useChartAccessibility"; |
| 45 | +import { useResizeObserverEffect } from '../useResizeObserverEffect'; |
46 | 46 | import img from "../img"; |
47 | 47 | import Title from "../atoms/Title.vue"; // Must be ready in responsive mode |
48 | 48 | import themes from "../themes.json"; |
@@ -141,7 +141,7 @@ const { loading, FINAL_DATASET, manualLoading } = useLoading({ |
141 | 141 | Promise.resolve().then(async () => { |
142 | 142 | await nextTick(); |
143 | 143 | if(heatmapChart.value) { |
144 | | - triggerResize(heatmapChart.value); |
| 144 | + triggerResize(heatmapChart.value, { delta: 0.1, delay: 250 }); |
145 | 145 | } |
146 | 146 | }) |
147 | 147 | }, |
@@ -339,56 +339,16 @@ const svg = computed(() => ({ |
339 | 339 | })); |
340 | 340 |
|
341 | 341 | const topLabelsHeight = ref(0); |
342 | | -
|
343 | | -const updateTopLabelsHeight = throttle((h) => { |
344 | | - topLabelsHeight.value = h |
345 | | -}, 100); |
346 | | -
|
347 | | -// Track time label height to update drawing area when they rotate |
348 | | -watchEffect((onInvalidate) => { |
349 | | - const el = xAxisLabels.value |
350 | | - if (!el) return |
351 | | -
|
352 | | - const observer = new ResizeObserver(entries => { |
353 | | - updateTopLabelsHeight(entries[0].contentRect.height) |
354 | | - }) |
355 | | - observer.observe(el) |
356 | | - onInvalidate(() => observer.disconnect()) |
357 | | -}); |
| 342 | +const updateTopLabelsHeight = throttle((h) => { topLabelsHeight.value = h }, 100); |
| 343 | +useResizeObserverEffect({ elementRef: xAxisLabels, callback: updateTopLabelsHeight, attr: 'height' }); |
358 | 344 |
|
359 | 345 | const leftLabelsWidth = ref(0); |
360 | | -
|
361 | | -const updateLeftLabelsWidth = throttle((h) => { |
362 | | - leftLabelsWidth.value = h |
363 | | -}, 100); |
364 | | -
|
365 | | -watchEffect((onInvalidate) => { |
366 | | - const el = yAxisLabels.value |
367 | | - if (!el) return |
368 | | -
|
369 | | - const observer = new ResizeObserver(entries => { |
370 | | - updateLeftLabelsWidth(entries[0].contentRect.width) |
371 | | - }) |
372 | | - observer.observe(el) |
373 | | - onInvalidate(() => observer.disconnect()) |
374 | | -}); |
| 346 | +const updateLeftLabelsWidth = throttle((h) => { leftLabelsWidth.value = h }, 100); |
| 347 | +useResizeObserverEffect({ elementRef: yAxisLabels, callback: updateLeftLabelsWidth, attr: 'width' }); |
375 | 348 |
|
376 | 349 | const xAxisSumLabelsHeight = ref(0); |
377 | | -
|
378 | | -const updateXAxisSumLabelsHeight = throttle((h) => { |
379 | | - xAxisSumLabelsHeight.value = h |
380 | | -}, 100); |
381 | | -
|
382 | | -watchEffect((onInvalidate) => { |
383 | | - const el = xAxisSums.value |
384 | | - if (!el) return |
385 | | -
|
386 | | - const observer = new ResizeObserver(entries => { |
387 | | - updateXAxisSumLabelsHeight(entries[0].contentRect.height) |
388 | | - }) |
389 | | - observer.observe(el) |
390 | | - onInvalidate(() => observer.disconnect()) |
391 | | -}); |
| 350 | +const updateXAxisSumLabelsHeight = throttle((h) => { xAxisSumLabelsHeight.value = h }, 100); |
| 351 | +useResizeObserverEffect({ elementRef: xAxisSums, callback: updateXAxisSumLabelsHeight, attr: 'height' }); |
392 | 352 |
|
393 | 353 | onBeforeUnmount(() => { |
394 | 354 | topLabelsHeight.value = 0; |
|
0 commit comments