Skip to content

Commit f51a527

Browse files
committed
play button and dropdown
1 parent 6c28995 commit f51a527

File tree

6 files changed

+44
-11
lines changed

6 files changed

+44
-11
lines changed

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"rc-slider": "^8.6.13",
5050
"rc-tooltip": "^3.7.3",
5151
"react": "^16.8.6",
52+
"react-16-dropdown": "^0.3.1",
5253
"react-dom": "^16.8.6",
5354
"react-json-tree": "^0.11.2",
5455
"redux-devtools-themes": "^1.0.0",

src/app/components/Dropdown.jsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { Component } from 'React'
2+
import Dropdown from 'react-16-dropdown';
3+
4+
const options = [{
5+
label: 'Prestige 🎩',
6+
value: 'prestige',
7+
}, {
8+
label: 'Inception 😴',
9+
value: 'inception',
10+
}];
11+
12+
<Dropdown
13+
align='left'
14+
className='custom-classname'
15+
closeOnEscape={true}
16+
options={options}
17+
triggerLabel='Movies'
18+
onClick={val => console.log(val)}
19+
/>
20+
21+
export default Dropdown;

src/app/containers/MainContainer.jsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class MainContainer extends Component {
1212
snapshotIndex: 0,
1313
currentIndex: null,
1414
port: null,
15+
pause: false,
1516
};
1617
this.handleChangeSnapshot = this.handleChangeSnapshot.bind(this);
1718
this.handleSendSnapshot = this.handleSendSnapshot.bind(this);
@@ -65,18 +66,22 @@ class MainContainer extends Component {
6566
playForward() {
6667
var play = setInterval(() => {
6768
const { snapshots, snapshotIndex } = this.state;
68-
if (snapshotIndex < snapshots.length - 1) {
69-
const newIndex = snapshotIndex + 1;
70-
this.handleJumpSnapshot(newIndex);
71-
this.setState({ snapshotIndex: newIndex });
72-
} else clearInterval(play);
69+
if (snapshotIndex < snapshots.length - 1 ) {
70+
const newIndex = snapshotIndex + 1;
71+
this.handleJumpSnapshot(newIndex);
72+
this.setState({ snapshotIndex: newIndex});
73+
} else {
74+
// this.setState({ playing: false });
75+
clearInterval(play);
76+
}
7377
}, 1000)
78+
7479
play();
7580
}
7681

7782
emptySnapshot() {
78-
const { port } = this.state;
79-
this.setState({ snapshots: [], snapshotIndex: 0 });
83+
const { port, snapshots } = this.state;
84+
this.setState({ snapshots: [snapshots[0]], snapshotIndex: 0 });
8085
port.postMessage({ action: 'emptySnap' });
8186
}
8287

@@ -124,7 +129,7 @@ class MainContainer extends Component {
124129
}
125130

126131
render() {
127-
const { snapshots, snapshotIndex } = this.state;
132+
const { snapshots, snapshotIndex, playing } = this.state;
128133
return (
129134
<div className="main-container">
130135
<HeadContainer />
@@ -138,6 +143,7 @@ class MainContainer extends Component {
138143
/>
139144
<StateContainer snapshot={snapshots[snapshotIndex]} />
140145
<TravelContainer
146+
playing = {playing}
141147
snapshotsLength={snapshots.length}
142148
handleChangeSnapshot={this.handleChangeSnapshot}
143149
handleJumpSnapshot={this.handleJumpSnapshot}

src/app/containers/TravelContainer.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from 'react';
2-
import MainSlider from '../components/MainSlider'
1+
import React, { Component } from 'react';
2+
import MainSlider from '../components/MainSlider';
33

44
const TravelContainer = ({
55
playForward,

src/extension/background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ chrome.runtime.onConnect.addListener((port) => {
2121
port.onMessage.addListener((msg) => {
2222
console.log('background -> contentScript', msg);
2323
if (msg.action === 'emptySnap') {
24-
snapshotArr = [];
24+
snapshotArr.splice(1);
2525
} else {
2626
// find active tab
2727
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {

0 commit comments

Comments
 (0)