code refactor

This commit is contained in:
saurabhg772244
2025-08-11 16:32:03 +05:30
parent 32723b2de1
commit e6fb4a84da
2 changed files with 11 additions and 5 deletions

View File

@@ -2,4 +2,4 @@
'mermaid': patch 'mermaid': patch
--- ---
Fix: Support edge animation in hand drawn look fix: Support edge animation in hand drawn look

View File

@@ -567,10 +567,10 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, startNod
let animationClass = ''; let animationClass = '';
if (edge.animate) { if (edge.animate) {
animationClass = ' edge-animation-fast'; animationClass = 'edge-animation-fast';
} }
if (edge.animation) { if (edge.animation) {
animationClass = ' edge-animation-' + edge.animation; animationClass = 'edge-animation-' + edge.animation;
} }
if (edge.look === 'handDrawn') { if (edge.look === 'handDrawn') {
@@ -589,7 +589,10 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, startNod
.attr('id', edge.id) .attr('id', edge.id)
.attr( .attr(
'class', 'class',
' ' + strokeClasses + (edge.classes ? ' ' + edge.classes : '') + (animationClass ?? '') ' ' +
strokeClasses +
(edge.classes ? ' ' + edge.classes : '') +
(animationClass ? ' ' + animationClass : '')
) )
.attr('style', edgeStyles ? edgeStyles.reduce((acc, style) => acc + ';' + style, '') : ''); .attr('style', edgeStyles ? edgeStyles.reduce((acc, style) => acc + ';' + style, '') : '');
let d = svgPath.attr('d'); let d = svgPath.attr('d');
@@ -606,7 +609,10 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, startNod
.attr('id', edge.id) .attr('id', edge.id)
.attr( .attr(
'class', 'class',
' ' + strokeClasses + (edge.classes ? ' ' + edge.classes : '') + (animationClass ?? '') ' ' +
strokeClasses +
(edge.classes ? ' ' + edge.classes : '') +
(animationClass ? ' ' + animationClass : '')
) )
.attr('style', pathStyle); .attr('style', pathStyle);
strokeColor = pathStyle.match(/stroke:([^;]+)/)?.[1]; strokeColor = pathStyle.match(/stroke:([^;]+)/)?.[1];