Skip to content

Commit 7e6d28b

Browse files
committed
feat: update animation to nodes and links
1 parent 27a4721 commit 7e6d28b

File tree

3 files changed

+49
-33
lines changed

3 files changed

+49
-33
lines changed

src/afd.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ function verifyAFD(paper, graph, automata, string) {
66
let symbol = string[i];
77

88
const interval = setInterval(() => {
9+
animateNode(
10+
paper,
11+
graph,
12+
state,
13+
symbol,
14+
automata.finalStates.includes(state)
15+
);
16+
917
if (i >= string.length) {
1018
clearInterval(interval);
1119

@@ -15,7 +23,7 @@ function verifyAFD(paper, graph, automata, string) {
1523
}
1624

1725
renderOut("INVALID");
18-
renderError("I do not end in a final state")
26+
renderError("I do not end in a final state");
1927
return;
2028
}
2129

@@ -35,14 +43,6 @@ function verifyAFD(paper, graph, automata, string) {
3543
return;
3644
}
3745

38-
animateNode(
39-
paper,
40-
graph,
41-
state,
42-
symbol,
43-
automata.finalStates.includes(state)
44-
);
45-
4646
i++;
4747
state = isState.nextState;
4848
symbol = string[i];

src/animateNode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ function animateNode(
66
state = "q0",
77
symbol,
88
isFinal,
9-
color = "#008080"
9+
color = "#f8d6ac"
1010
) {
1111
const data = paper.model
1212
.getElements()
1313
.find((el) => el.attributes.attrs.label.text === state);
1414

1515
data.attr("body/stroke", color);
16-
data.attr("body/fill", "#21bcbc");
16+
data.attr("body/fill", color);
1717

1818
const links = graph.getConnectedLinks(data, { outbound: true });
1919

src/styles.css

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,42 @@ input:focus {
66
outline: none;
77
}
88

9+
#string-out {
10+
display: flex;
11+
gap: 0.5rem;
12+
}
13+
14+
.symbol {
15+
position: relative;
16+
display: block;
17+
transition: all 200ms;
18+
}
19+
20+
.symbol-active::after {
21+
transition: all 200ms;
22+
position: absolute;
23+
content: "";
24+
background-image: url(https://www.transparentpng.com/thumb/up-arrow/m6xCB1-up-arrow-vector.png);
25+
background-size: cover;
26+
width: 25px;
27+
height: 25px;
28+
display: block;
29+
top: -10;
30+
left: -6px;
31+
}
32+
33+
/* JOINTJS */
34+
935
.joint-paper {
1036
border: none !important;
1137
background-color: #fff !important;
1238
border-bottom: 2px #e5e7eb solid !important;
1339
}
1440

41+
.joint-type-circle ellipse {
42+
transition: all 200ms;
43+
}
44+
1545
.joint-link.current path {
1646
stroke-dasharray: 5;
1747
stroke-dashoffset: 10;
@@ -24,6 +54,10 @@ input:focus {
2454
}
2555
}
2656

57+
/* END JOINTJS */
58+
59+
/* SPLITJS */
60+
2761
.split {
2862
display: flex;
2963
flex-direction: row;
@@ -40,29 +74,9 @@ input:focus {
4074
cursor: col-resize;
4175
}
4276

43-
#string-out {
44-
display: flex;
45-
gap: 0.5rem;
46-
}
47-
48-
.symbol {
49-
position: relative;
50-
display: block;
51-
transition: all 200ms;
52-
}
77+
/* END SPLITJS */
5378

54-
.symbol-active::after {
55-
transition: all 200ms;
56-
position: absolute;
57-
content: "";
58-
background-image: url(https://www.transparentpng.com/thumb/up-arrow/m6xCB1-up-arrow-vector.png);
59-
background-size: cover;
60-
width: 25px;
61-
height: 25px;
62-
display: block;
63-
top: -10;
64-
left: -6px;
65-
}
79+
/* MODALS */
6680

6781
.modal {
6882
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir,
@@ -228,6 +242,8 @@ input:focus {
228242
will-change: transform;
229243
}
230244

245+
/* END MODALS */
246+
231247
/* ANIMATIONS */
232248
.animate__fadeIn {
233249
opacity: 0;

0 commit comments

Comments
 (0)