Skip to content

Commit c92d8d6

Browse files
committed
Fix - VueUiFlow - Remove excessive bottom padding
1 parent 5a583e2 commit c92d8d6

File tree

4 files changed

+14
-29
lines changed

4 files changed

+14
-29
lines changed

TestingArena/ArenaVueUiFlow.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ const model = ref([
144144
{ key: 'userOptions.showOnChartHover', def: true, type: 'checkbox' },
145145
{ key: 'userOptions.keepStateOnChartLeave', def: true, type: 'checkbox' },
146146
147+
{ key: 'style.chart.padding.top', def: 12, type: 'number', min: 0, max: 100,},
148+
{ key: 'style.chart.padding.right', def: 12, type: 'number', min: 0, max: 100,},
149+
{ key: 'style.chart.padding.bottom', def: 12, type: 'number', min: 0, max: 100,},
150+
{ key: 'style.chart.padding.left', def: 12, type: 'number', min: 0, max: 100,},
151+
147152
{ key: 'userOptions.print.scale', def: 2, type: 'number', min: 1, max: 5 },
148153
{ key: 'userOptions.print.allowTaint', def: true, type: 'checkbox' },
149154
{ key: 'userOptions.print.useCORS', def: true, type: 'checkbox' },

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@
110110
"vitest": "^3.1.1",
111111
"vue": "^3.5.14"
112112
}
113-
}
113+
}

src/components/vue-ui-flow.vue

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -412,34 +412,14 @@ function computeTotalHeight(nodeCoordinates) {
412412
}
413413
414414
const drawingArea = computed(() => {
415-
const pad = FINAL_CONFIG.value.style.chart.padding;
416-
const padTop = pad.top;
417-
const padBottom = pad.bottom;
418-
const padLeft = pad.left;
419-
const padRight = pad.right;
420-
421-
const maxX = mutableDataset.value.nodes.reduce(
422-
(mx, n) => Math.max(mx, n.x),
423-
0
415+
const { top: pTop, right: pRight, bottom: pBottom, left: pLeft } = FINAL_CONFIG.value.style.chart.padding;
416+
const maxNodeX = Math.max(...mutableDataset.value.nodes.map(n => n.x));
417+
const width = pLeft + maxNodeX + nodeWidth.value + pRight;
418+
const maxNodeBottom = Math.max(
419+
...mutableDataset.value.nodes.map(n => n.absoluteY + n.height)
424420
);
425-
const width = padLeft + maxX + nodeWidth.value + padRight;
426-
427-
const maxNodeBottom = mutableDataset.value.nodes.reduce((mb, n) => {
428-
const nodeTop = n.y + padTop;
429-
const nodeBot = nodeTop + n.height;
430-
return Math.max(mb, nodeBot);
431-
}, 0);
432-
433-
const height = maxNodeBottom + padBottom;
434-
435-
return {
436-
width,
437-
height,
438-
left: padLeft,
439-
top: padTop,
440-
right: padRight,
441-
bottom: padBottom
442-
};
421+
const height = pTop + maxNodeBottom + pBottom;
422+
return { width, height };
443423
});
444424
445425
function findConnectedNodes(startNode) {

src/useConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3875,7 +3875,7 @@ export function useConfig() {
38753875
chart: {
38763876
backgroundColor: COLOR_WHITE,
38773877
color: COLOR_BLACK,
3878-
padding: PADDING([12, 12, 0, 12]),
3878+
padding: PADDING([12, 12, 12, 12]),
38793879
title: TITLE,
38803880
tooltip: {
38813881
...TOOLTIP,

0 commit comments

Comments
 (0)