Skip to content

Commit 40fb77c

Browse files
authored
Update SortingVisualizer.jsx
Comments added
1 parent ab6319e commit 40fb77c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Visualizer/SortingVisualizer.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,52 @@ export default class SortingVisualizer extends React.Component {
1717
array:[],
1818
}
1919
}
20-
20+
//reload the page
2121
componentDidMount(){
2222
this.generateNewArray();
2323
window.addEventListener("resize", this.generateNewArray.bind(this));
2424
}
25-
25+
26+
//create a new array of random numbers
2627
generateNewArray = () => {
2728
let arr = generator();
2829
this.setState({
2930
array:arr
3031
})
3132
}
3233

34+
//bubbleSort button implementation
3335
bubbleSort = () => {
3436
removeButton();
3537
const animations = getBuubleSortAnimations(this.state.array);
3638
performAnimation(animations).then(document.querySelector('#clear').disabled = false)
3739

3840
}
3941

42+
//selectionSort button implementation
4043
selectionSort = () => {
4144
removeButton();
4245
const animations = getSelectionSortAnimations(this.state.array);
4346
performAnimation(animations).then(document.querySelector('#clear').disabled = false)
4447
}
4548

49+
//insertionSort button implementation
4650
insertionSort = () => {
4751
removeButton();
4852
const animations = getInsertionSortAnimations(this.state.array);
4953
performAnimation(animations).then(document.querySelector('#clear').disabled = false)
5054

5155
}
5256

57+
//mergeSort button implementation
5358
mergeSort = () => {
5459
removeButton();
5560
const animations = getMergeSortAnimations(this.state.array);
5661
performAnimation(animations).then(document.querySelector('#clear').disabled = false)
5762

5863
}
59-
64+
65+
//reload screen on clear button
6066
clear = () => {
6167
window.location.reload(false);
6268
return false;

0 commit comments

Comments
 (0)