Skip to content

Commit b37660a

Browse files
Merge pull request #2 from oslabs-beta/playButton
changes to the play button
2 parents bfb9b95 + b30eb7a commit b37660a

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

src/app/actions/actions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,7 @@ export const deleteTab = tab => ({
7272
type: types.DELETE_TAB,
7373
payload: tab,
7474
});
75+
76+
export const resetSlider = slider => ({
77+
type: types.SLIDER_ZERO,
78+
});

src/app/constants/actionTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ export const INITIAL_CONNECT = 'INITIAL_CONNECT';
1212
export const NEW_SNAPSHOTS = 'NEW_SNAPSHOTS';
1313
export const SET_TAB = 'SET_TAB';
1414
export const DELETE_TAB = 'DELETE_TAB';
15+
export const SLIDER_ZERO = 'SLIDER_ZERO';

src/app/containers/TravelContainer.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ function play(speed, playing, dispatch, snapshotsLength, sliderIndex) {
1919
dispatch(pause());
2020
} else {
2121
let currentIndex = sliderIndex;
22+
if (currentIndex === snapshotsLength - 1) {
23+
// dispatch action to reset the slider
24+
dispatch(resetSlider());
25+
currentIndex = 0;
26+
}
2227
const intervalId = setInterval(() => {
2328
if (currentIndex < snapshotsLength - 1) {
2429
dispatch(playForward());

src/app/reducers/mainReducer.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ export default (state, action) => produce(state, draft => {
4747
}
4848
break;
4949
}
50+
case types.SLIDER_ZERO: {
51+
console.log('main reducer Slider Zero')
52+
port.postMessage({
53+
action: 'jumpToSnap',
54+
index: 0,
55+
payload: snapshots[0],
56+
tabId: currentTab,
57+
});
58+
tabs[currentTab].sliderIndex = 0;
59+
break;
60+
}
5061
case types.CHANGE_VIEW: {
5162
// unselect view if same index was selected
5263
if (viewIndex === action.payload) tabs[currentTab].viewIndex = -1;

0 commit comments

Comments
 (0)