Skip to content

Commit 4375bee

Browse files
committed
updated timing
1 parent 19a1d31 commit 4375bee

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/services/utils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ const EXPAND_DELAY = 10;
55
// Function to color nodes
66

77
export const colorNodes = (path: any[], expanded: any) => {
8-
const timeToAnimateExpanded = (expanded?.length || 0) * EXPAND_DELAY;
8+
// get expanded time
9+
const expandedTime = (expanded?.length || 0) * EXPAND_DELAY;
910
// get node html element by row and col
1011
const getNodeElement = ([row, col]: any) =>
1112
document.querySelector(
@@ -28,7 +29,7 @@ export const colorNodes = (path: any[], expanded: any) => {
2829
}
2930
});
3031

31-
// Color path nodes
32+
// Color path nodes after we colored expanded
3233
setTimeout(() => {
3334
path.forEach((node: any) => {
3435
const el = getNodeElement(node);
@@ -37,13 +38,15 @@ export const colorNodes = (path: any[], expanded: any) => {
3738
!el.classList.contains("objective") &&
3839
!el.classList.contains("start")
3940
) {
41+
// remove expanded class from path nodes
4042
if (el.classList.contains("expanded")) {
4143
el.classList.remove("expanded");
4244
}
45+
// add path class
4346
el.classList.add("path");
4447
}
4548
});
46-
}, timeToAnimateExpanded * 2);
49+
}, expandedTime * 1.1);
4750
};
4851

4952
export const startSorting = (animations: any[]) => {

0 commit comments

Comments
 (0)