Skip to content

Commit 3ae4c67

Browse files
committed
Updated Animation and Frame classes.
1 parent a8b39de commit 3ae4c67

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

script/algorithms.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
class Frame {
2-
Frame() {}
2+
constructor(e, h) {
3+
this.elements = [];
4+
this.highlights = [];
5+
6+
if (e != undefined && e.length) {
7+
this.elements = e;
8+
}
9+
10+
if (h != undefined && h.length) {
11+
this.highlights = h;
12+
}
13+
}
314

415
addHighlights(highlights) {
516
for (const e of highlights) {
@@ -17,13 +28,12 @@ class Frame {
1728
this.highlights.length = 0;
1829
this.elements.length = 0;
1930
}
20-
21-
elements = Array();
22-
highlights = Array();
2331
}
2432

2533
class Animation {
26-
Animation() {}
34+
constructor() {
35+
this.frames = [];
36+
}
2737

2838
addFrame(frame) {
2939
// Only store a copy

0 commit comments

Comments
 (0)