Skip to content

Commit cbd9115

Browse files
committed
Fix - VueUiHeatmap - Fit time time labels on load when they are rotated
1 parent b4f23ab commit cbd9115

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/components/vue-ui-heatmap.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ const { loading, FINAL_DATASET, manualLoading } = useLoading({
140140
callback: () => {
141141
Promise.resolve().then(async () => {
142142
await nextTick();
143-
if(heatmapChart.value && heatmapChart.value.parentNode) {
144-
triggerResize(heatmapChart.value.parentNode);
143+
if(heatmapChart.value) {
144+
triggerResize(heatmapChart.value);
145145
}
146146
})
147147
},

src/lib.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,7 +3269,6 @@ export function triggerResize(el, { delta = 1, delay = 20, disableTransitions =
32693269
if (!el || !(el instanceof HTMLElement)) return;
32703270

32713271
const style = el.style;
3272-
32733272
const prev = {
32743273
width: style.width,
32753274
height: style.height,
@@ -3280,22 +3279,27 @@ export function triggerResize(el, { delta = 1, delay = 20, disableTransitions =
32803279
const w = rect.width;
32813280
const h = rect.height;
32823281

3283-
if (disableTransitions) {
3284-
style.transition = 'none';
3285-
}
3282+
if (disableTransitions) style.transition = 'none';
3283+
3284+
const isRelative = (v) => /%|em|rem/.test(v);
3285+
3286+
style.width = prev.width && isRelative(prev.width)
3287+
? `calc(${prev.width} + ${delta}px)`
3288+
: `${Math.max(0, w + delta)}px`;
32863289

3287-
style.width = `${Math.max(0, w + delta)}px`;
3288-
style.height = `${Math.max(0, h + delta)}px`;
3289-
el.offsetWidth;
3290+
style.height = prev.height && isRelative(prev.height)
3291+
? `calc(${prev.height} + ${delta}px)`
3292+
: `${Math.max(0, h + delta)}px`;
3293+
3294+
void el.offsetWidth;
32903295

32913296
setTimeout(() => {
32923297
style.width = prev.width;
32933298
style.height = prev.height;
3294-
el.offsetWidth;
3299+
void el.offsetWidth;
3300+
32953301
requestAnimationFrame(() => {
3296-
if (disableTransitions) {
3297-
style.transition = prev.transition;
3298-
}
3302+
if (disableTransitions) style.transition = prev.transition;
32993303
});
33003304
}, delay);
33013305
}

0 commit comments

Comments
 (0)