@@ -5,7 +5,8 @@ const EXPAND_DELAY = 10;
55// Function to color nodes
66
77export 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
4952export const startSorting = ( animations : any [ ] ) => {
0 commit comments