Skip to content

Commit

Permalink
Add increment back arrow to time player (apache#6062)
Browse files Browse the repository at this point in the history
* Working on CSS

* Will fix CSS later

* Simplify PR

(cherry picked from commit 3cc6fb6)
  • Loading branch information
betodealmeida committed Oct 30, 2018
1 parent 4b8c3a0 commit 3717719
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions superset/assets/src/visualizations/PlaySlider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export default class PlaySlider extends React.PureComponent {
this.onChange = this.onChange.bind(this);
this.play = this.play.bind(this);
this.pause = this.pause.bind(this);
this.step = this.step.bind(this);
this.stepBackward = this.stepBackward.bind(this);
this.stepForward = this.stepForward.bind(this);
this.getPlayClass = this.getPlayClass.bind(this);
this.formatter = this.formatter.bind(this);
}
Expand Down Expand Up @@ -76,15 +77,15 @@ export default class PlaySlider extends React.PureComponent {
if (this.state.intervalId != null) {
this.pause();
} else {
const id = setInterval(this.step, this.intervalMilliseconds);
const id = setInterval(this.stepForward, this.intervalMilliseconds);
this.setState({ intervalId: id });
}
}
pause() {
clearInterval(this.state.intervalId);
this.setState({ intervalId: null });
}
step() {
stepForward() {
const { start, end, step, values, disabled } = this.props;

if (disabled) {
Expand All @@ -97,6 +98,19 @@ export default class PlaySlider extends React.PureComponent {

this.props.onChange(nextValues.map(value => value - carriageReturn));
}
stepBackward() {
const { start, end, step, values, disabled } = this.props;

if (disabled) {
return;
}

const currentValues = Array.isArray(values) ? values : [values, values + step];
const nextValues = currentValues.map(value => value - this.increment);
const carriageReturn = (nextValues[0] < start) ? (end - nextValues[1]) : 0;

this.props.onChange(nextValues.map(value => value + carriageReturn));
}
formatter(values) {
if (this.props.disabled) {
return t('Data has no time steps');
Expand All @@ -115,8 +129,9 @@ export default class PlaySlider extends React.PureComponent {
return (
<Row className="play-slider">
<Col md={1} className="padded">
<i className="fa fa-step-backward fa-lg slider-button " onClick={this.stepBackward} />
<i className={this.getPlayClass()} onClick={this.play} />
<i className="fa fa-step-forward fa-lg slider-button " onClick={this.step} />
<i className="fa fa-step-forward fa-lg slider-button " onClick={this.stepForward} />
</Col>
<Col md={11} className="padded">
<BootrapSliderWrapper
Expand Down

0 comments on commit 3717719

Please sign in to comment.