mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 07:19:41 +02:00
fix: fix sizing of sl-rect
in fixed layout
This commit is contained in:
@@ -7,12 +7,26 @@ import rough from 'roughjs';
|
||||
export const slopedRect = async (parent: SVGAElement, node: Node) => {
|
||||
const { labelStyles, nodeStyles } = styles2String(node);
|
||||
node.labelStyle = labelStyles;
|
||||
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
const nodePadding = node.padding ?? 0;
|
||||
const labelPaddingX = node.look === 'neo' ? nodePadding * 2 : nodePadding;
|
||||
const labelPaddingY = node.look === 'neo' ? nodePadding * 1 : nodePadding;
|
||||
const w = Math.max(bbox.width + (labelPaddingX ?? 0) * 2, node?.width ?? 0);
|
||||
const h = Math.max(bbox.height + (labelPaddingY ?? 0) * 2, node?.height ?? 0);
|
||||
|
||||
// If incoming height & width are present, subtract the padding from them
|
||||
// as labelHelper does not take padding into account
|
||||
// also check if the width or height is less than minimum default values (50),
|
||||
// if so set it to min value
|
||||
if (node.width || node.height) {
|
||||
node.width = Math.max((node?.width ?? 0) - labelPaddingX * 2, 50);
|
||||
node.height = Math.max((node?.height ?? 0) / 1.5 - labelPaddingY * 2, 50);
|
||||
}
|
||||
|
||||
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const totalWidth = Math.max(bbox.width, node?.width ?? 0) + labelPaddingX * 2;
|
||||
const totalHeight = (Math.max(bbox.height, node?.height ?? 0) + labelPaddingY * 2) * 1.5;
|
||||
|
||||
const w = totalWidth;
|
||||
const h = totalHeight / 1.5;
|
||||
const x = -w / 2;
|
||||
const y = -h / 2;
|
||||
|
||||
|
Reference in New Issue
Block a user