File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -365,7 +365,14 @@ class App extends React.Component {
365365
366366 handleSpeedChange = ( event ) => {
367367 const newSpeed = parseInt ( event . target . value ) ;
368- this . setState ( { playSpeed : newSpeed } ) ;
368+ this . setState ( { playSpeed : newSpeed } , ( ) => {
369+ if ( this . state . isPlaying ) {
370+ clearInterval ( this . timerID ) ;
371+ this . timerID = setInterval ( ( ) => {
372+ this . handleNextEvent ( ) ;
373+ } , newSpeed ) ;
374+ }
375+ } ) ;
369376 } ;
370377
371378 handleKeyPress = ( event ) => {
@@ -1077,11 +1084,8 @@ class App extends React.Component {
10771084 </ div >
10781085 < div >
10791086 < button onClick = { this . handlePlayStop } > { this . state . isPlaying ? "Stop" : "Play" } </ button >
1080- < select
1081- value = { this . state . playSpeed }
1082- onChange = { this . handleSpeedChange }
1083- disabled = { this . state . isPlaying }
1084- >
1087+ < select value = { this . state . playSpeed } onChange = { this . handleSpeedChange } >
1088+ < option value = "100" > 0.1s</ option >
10851089 < option value = "250" > 0.25s</ option >
10861090 < option value = "500" > 0.5s</ option >
10871091 < option value = "1000" > 1s</ option >
You can’t perform that action at this time.
0 commit comments