Skip to content

Commit 8768ef5

Browse files
committed
added comments on play pause function
1 parent 4a198fe commit 8768ef5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/app/containers/MainContainer.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,13 @@ class MainContainer extends Component {
8383
}
8484

8585
play() {
86+
// flip glboal variable onClick
8687
globalPlaying = !globalPlaying
88+
// set state with callback of setInterval
8789
this.setState({playing: globalPlaying}, () => {
90+
// check if playing is false, if false run interval
8891
if(this.state.playing){
92+
// store intervalId to global vairable interval Id
8993
intervalId = setInterval(() => {
9094
const { snapshots, snapshotIndex } = this.state;
9195
if (snapshotIndex < snapshots.length - 1) {
@@ -99,12 +103,14 @@ class MainContainer extends Component {
99103
}
100104
}, 1000);
101105
} else {
106+
// menas already playing, user wants to pause so clearinterval using global vairable
102107
clearInterval(intervalId);
103108
}
104109
})
105110
}
106111

107112
pause() {
113+
// clearInterval and set playing to false, used for onChange and forward,backward button on travel container
108114
this.setState({playing: false}, clearInterval(intervalId))
109115
}
110116

0 commit comments

Comments
 (0)