File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -83,9 +83,13 @@ class MainContainer extends Component {
83
83
}
84
84
85
85
play ( ) {
86
+ // flip glboal variable onClick
86
87
globalPlaying = ! globalPlaying
88
+ // set state with callback of setInterval
87
89
this . setState ( { playing : globalPlaying } , ( ) => {
90
+ // check if playing is false, if false run interval
88
91
if ( this . state . playing ) {
92
+ // store intervalId to global vairable interval Id
89
93
intervalId = setInterval ( ( ) => {
90
94
const { snapshots, snapshotIndex } = this . state ;
91
95
if ( snapshotIndex < snapshots . length - 1 ) {
@@ -99,12 +103,14 @@ class MainContainer extends Component {
99
103
}
100
104
} , 1000 ) ;
101
105
} else {
106
+ // menas already playing, user wants to pause so clearinterval using global vairable
102
107
clearInterval ( intervalId ) ;
103
108
}
104
109
} )
105
110
}
106
111
107
112
pause ( ) {
113
+ // clearInterval and set playing to false, used for onChange and forward,backward button on travel container
108
114
this . setState ( { playing : false } , clearInterval ( intervalId ) )
109
115
}
110
116
You can’t perform that action at this time.
0 commit comments