Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add animated class to the dotted links #5650

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,16 @@ export const addEdges = async function (edges, g, _diagObj) {

let style = '';
let labelStyle = '';
let isAnimatedProducerNode = g.node(edge.start).class.split(' ').includes('producer');
let isAnimatedConsumerNode = g.node(edge.end).class.split(' ').includes('consumer');

let linkAnimatedDashClass =
edge.stroke === 'dotted' &&
edge.type === 'arrow_point' &&
isAnimatedProducerNode &&
isAnimatedConsumerNode
? 'animated'
: '';

switch (edge.stroke) {
case 'normal':
Expand Down Expand Up @@ -329,7 +339,9 @@ export const addEdges = async function (edges, g, _diagObj) {
edgeData.labelStyle = edgeData.labelStyle.replace('color:', 'fill:');

edgeData.id = linkId;
edgeData.classes = 'flowchart-link ' + linkNameStart + ' ' + linkNameEnd;
edgeData.classes = ['flowchart-link', linkAnimatedDashClass, linkNameStart, linkNameEnd].join(
' '
);

// Add the edge to the graph
g.setEdge(edge.start, edge.end, edgeData, cnt);
Expand Down
10 changes: 9 additions & 1 deletion packages/mermaid/src/diagrams/flowchart/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ const getStyles = (options: FlowChartStyleOptions) =>
/* For html labels only */
.labelBkg {
background-color: ${fade(options.edgeLabelBackground, 0.5)};
// background-color:
}

.cluster rect {
Expand Down Expand Up @@ -145,6 +144,15 @@ const getStyles = (options: FlowChartStyleOptions) =>
font-size: 18px;
fill: ${options.textColor};
}

.animated {
animation: animate-dash-line 5s linear infinite;
}

@keyframes animate-dash-line {
from { stroke-dashoffset: 102; }
to { stroke-dashoffset: 0; }
}
`;

export default getStyles;
Loading