mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-03 22:29:38 +02:00
fixed some label transform for htmlLabels false
This commit is contained in:
@@ -57,7 +57,7 @@ export const dividedRect = async (parent: SVGAElement, node: Node) => {
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${x + (node.padding ?? 0) / 2}, ${y + rectOffset + (node.padding ?? 0) / 2})`
|
||||
`translate(${x + (node.padding ?? 0) / 2 - (bbox.x - (bbox.left ?? 0))}, ${y + rectOffset + (node.padding ?? 0) / 2 - 4 * (bbox.y - (bbox.top ?? 0))})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, polygon);
|
||||
|
@@ -53,7 +53,10 @@ export const flippedTriangle = async (parent: SVGAElement, node: Node): Promise<
|
||||
|
||||
updateNodeBounds(node, flippedTriangle);
|
||||
|
||||
label.attr('transform', `translate(${-bbox.width / 2}, ${-h / 2})`);
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${-h / 2 + 4 * (bbox.y - (bbox.top ?? 0))})`
|
||||
);
|
||||
|
||||
node.intersect = function (point) {
|
||||
log.info('Triangle intersect', node, points, point);
|
||||
|
@@ -52,7 +52,7 @@ export const halfRoundedRectangle = async (parent: SVGAElement, node: Node) => {
|
||||
polygon.attr('transform', `translate(${-w / 2 - h / 4}, ${-h / 2})`);
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-w / 2 + (node.padding ?? 0) - h / 4}, ${-h / 2 + (node.padding ?? 0)})`
|
||||
`translate(${-w / 2 + (node.padding ?? 0) - h / 4 - (bbox.x - (bbox.left ?? 0))}, ${-h / 2 + (node.padding ?? 0) - 4 * (bbox.y - (bbox.top ?? 0))})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, polygon);
|
||||
|
@@ -65,7 +65,10 @@ export const linedCylinder = async (parent: SVGAElement, node: Node) => {
|
||||
|
||||
updateNodeBounds(node, cylinder);
|
||||
|
||||
label.attr('transform', `translate(${-bbox.width / 2}, ${h / 2 - bbox.height + outerOffset})`);
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${h / 2 - bbox.height + outerOffset - 4 * (bbox.y - (bbox.top ?? 0))})`
|
||||
);
|
||||
|
||||
node.intersect = function (point) {
|
||||
const pos = intersect.rect(node, point);
|
||||
|
@@ -71,7 +71,7 @@ export const multiRect = async (parent: SVGAElement, node: Node) => {
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-(bbox.width / 2) - rectOffset}, ${-(bbox.height / 2) + rectOffset})`
|
||||
`translate(${-(bbox.width / 2) - rectOffset - (bbox.x - (bbox.left ?? 0))}, ${-(bbox.height / 2) + rectOffset - 4 * (bbox.y - (bbox.top ?? 0))})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, multiRect);
|
||||
|
@@ -51,7 +51,7 @@ export const slopedRect = async (parent: SVGAElement, node: Node) => {
|
||||
polygon.attr('transform', `translate(0, ${h / 4})`);
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-w / 2 + (node.padding ?? 0)}, ${-h / 4 + (node.padding ?? 0)})`
|
||||
`translate(${-w / 2 + (node.padding ?? 0) - (bbox.x - (bbox.left ?? 0))}, ${-h / 4 + (node.padding ?? 0) - 4 * (bbox.y - (bbox.top ?? 0))})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, polygon);
|
||||
|
@@ -53,7 +53,10 @@ export const triangle = async (parent: SVGAElement, node: Node): Promise<SVGAEle
|
||||
|
||||
updateNodeBounds(node, polygon);
|
||||
|
||||
label.attr('transform', `translate(${-bbox.width / 2}, ${h / 2 - bbox.height})`);
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${h / 2 - bbox.height - 4 * (bbox.y - (bbox.top ?? 0))})`
|
||||
);
|
||||
|
||||
node.intersect = function (point) {
|
||||
log.info('Triangle intersect', node, points, point);
|
||||
|
@@ -54,7 +54,7 @@ export const waveEdgedRectangle = async (parent: SVGAElement, node: Node) => {
|
||||
waveEdgeRect.attr('transform', `translate(0,${-waveAmplitude / 2})`);
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-w / 2 + (node.padding ?? 0)},${-h / 2 + (node.padding ?? 0) - waveAmplitude / 2})`
|
||||
`translate(${-w / 2 + (node.padding ?? 0) - (bbox.x - (bbox.left ?? 0))},${-h / 2 + (node.padding ?? 0) - waveAmplitude / 2 - 4 * (bbox.y - (bbox.top ?? 0))})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, waveEdgeRect);
|
||||
|
@@ -68,7 +68,7 @@ export const windowPane = async (parent: SVGAElement, node: Node) => {
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-(bbox.width / 2) + rectOffset / 2}, ${-(bbox.height / 2) + rectOffset / 2})`
|
||||
`translate(${-(bbox.width / 2) + rectOffset / 2 - (bbox.x - (bbox.left ?? 0))}, ${-(bbox.height / 2) + rectOffset / 2 - 4 * (bbox.y - (bbox.top ?? 0))})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, windowPane);
|
||||
|
Reference in New Issue
Block a user