File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -17,46 +17,52 @@ export default class SortingVisualizer extends React.Component {
17
17
array :[ ] ,
18
18
}
19
19
}
20
-
20
+ //reload the page
21
21
componentDidMount ( ) {
22
22
this . generateNewArray ( ) ;
23
23
window . addEventListener ( "resize" , this . generateNewArray . bind ( this ) ) ;
24
24
}
25
-
25
+
26
+ //create a new array of random numbers
26
27
generateNewArray = ( ) => {
27
28
let arr = generator ( ) ;
28
29
this . setState ( {
29
30
array :arr
30
31
} )
31
32
}
32
33
34
+ //bubbleSort button implementation
33
35
bubbleSort = ( ) => {
34
36
removeButton ( ) ;
35
37
const animations = getBuubleSortAnimations ( this . state . array ) ;
36
38
performAnimation ( animations ) . then ( document . querySelector ( '#clear' ) . disabled = false )
37
39
38
40
}
39
41
42
+ //selectionSort button implementation
40
43
selectionSort = ( ) => {
41
44
removeButton ( ) ;
42
45
const animations = getSelectionSortAnimations ( this . state . array ) ;
43
46
performAnimation ( animations ) . then ( document . querySelector ( '#clear' ) . disabled = false )
44
47
}
45
48
49
+ //insertionSort button implementation
46
50
insertionSort = ( ) => {
47
51
removeButton ( ) ;
48
52
const animations = getInsertionSortAnimations ( this . state . array ) ;
49
53
performAnimation ( animations ) . then ( document . querySelector ( '#clear' ) . disabled = false )
50
54
51
55
}
52
56
57
+ //mergeSort button implementation
53
58
mergeSort = ( ) => {
54
59
removeButton ( ) ;
55
60
const animations = getMergeSortAnimations ( this . state . array ) ;
56
61
performAnimation ( animations ) . then ( document . querySelector ( '#clear' ) . disabled = false )
57
62
58
63
}
59
-
64
+
65
+ //reload screen on clear button
60
66
clear = ( ) => {
61
67
window . location . reload ( false ) ;
62
68
return false ;
You can’t perform that action at this time.
0 commit comments