You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This container renders the time-travel play button, seek bar, playback controls, and the playback speed dropdown, located towards the bottom of the application, above the locked, download, upload, and tutorial buttons
21
24
*/
@@ -29,14 +32,15 @@ const speeds: {
29
32
{value: 1000,label: '1.0x'},
30
33
{value: 500,label: '2.0x'},
31
34
];
32
-
35
+
//NOTE HERE REMOVED THE DISPATCH FUNCTION IN THE TYPE SCRIPT:
36
+
//USING THE BUILT IN DISPATCH
33
37
functionplay(// function that will start/pause slider movement
34
38
speed: number,
35
39
playing: boolean,
36
-
dispatch: (a: any)=>void,
37
40
snapshotsLength: number,
38
41
sliderIndex: number,
39
42
): void{
43
+
constdispatch=useDispatch();
40
44
if(playing){// if already playing, clicking the button will pause the slider
41
45
dispatch(pause());
42
46
}else{
@@ -47,7 +51,7 @@ function play( // function that will start/pause slider movement
47
51
}
48
52
constintervalId: NodeJS.Timeout=setInterval(()=>{// sets interval period to wait before advancing 'currentIndex'/slider
49
53
if(currentIndex<snapshotsLength-1){// as long as we're not the last snapshot, increment slider up through our dispatch and increment index
50
-
dispatch(playForward());
54
+
dispatch(playForward(true));
51
55
currentIndex+=1;
52
56
}else{
53
57
dispatch(pause());// pause the slider when we reach the end
@@ -60,8 +64,12 @@ function play( // function that will start/pause slider movement
const[selectedSpeed,setSpeed]=useState(speeds[1]);// create a new local state selectedSpeed and set it to the second element of the 'speeds' array (1.0x speed)
63
-
const[{ tabs, currentTab },dispatch]=useStoreContext();// we destructure the returned context object from the invocation of the useStoreContext function. Properties not found on the initialState object (dispatch) are from the useReducer function invocation in the App component
64
-
const{ sliderIndex, playing }=tabs[currentTab];// we destructure the currentTab object
67
+
68
+
// const [{ tabs, currentTab }, dispatch] = useStoreContext(); // we destructure the returned context object from the invocation of the useStoreContext function. Properties not found on the initialState object (dispatch) are from the useReducer function invocation in the App component
69
+
// const { sliderIndex, playing } = tabs[currentTab]; // we destructure the currentTab object
0 commit comments