summaryrefslogtreecommitdiff
path: root/src/components/timeline
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/timeline')
-rw-r--r--src/components/timeline/TimelineComponent.js10
-rw-r--r--src/components/timeline/TimelineControlsComponent.js56
2 files changed, 33 insertions, 33 deletions
diff --git a/src/components/timeline/TimelineComponent.js b/src/components/timeline/TimelineComponent.js
index b400a378..119c396b 100644
--- a/src/components/timeline/TimelineComponent.js
+++ b/src/components/timeline/TimelineComponent.js
@@ -11,15 +11,9 @@ class TimelineComponent extends React.Component {
}
if (this.props.currentTick < this.props.lastSimulatedTick) {
- for (let i in this.props.sections.reverse()) {
- if (this.props.currentTick + 1 >= this.props.sections[i].startTick) {
- if (this.props.currentDatacenterId !== this.props.sections[i].datacenterId) {
- this.props.setCurrentDatacenter(this.props.sections[i].datacenterId);
- }
- break;
- }
- }
this.props.incrementTick();
+ } else {
+ this.props.pauseSimulation();
}
}, 1000);
}
diff --git a/src/components/timeline/TimelineControlsComponent.js b/src/components/timeline/TimelineControlsComponent.js
index 2e093583..bd98afc3 100644
--- a/src/components/timeline/TimelineControlsComponent.js
+++ b/src/components/timeline/TimelineControlsComponent.js
@@ -1,33 +1,39 @@
import React from "react";
import PlayButtonContainer from "../../containers/timeline/PlayButtonContainer";
+import {convertTickToPercentage} from "../../util/timeline";
-function getXPercentage(tick, maxTick) {
- if (maxTick === 0) {
- return "0%";
- } else if (tick > maxTick) {
- return ((maxTick / (maxTick + 1)) * 100) + "%";
+class TimelineControlsComponent extends React.Component {
+ onTimelineClick(e) {
+ const percentage = e.nativeEvent.offsetX / this.timeline.clientWidth;
+ const tick = Math.floor(percentage * (this.props.lastSimulatedTick + 1));
+ this.props.goToTick(tick);
}
- return ((tick / (maxTick + 1)) * 100) + "%";
-}
-
-const TimelineControlsComponent = ({currentTick, lastSimulatedTick, sectionTicks}) => (
- <div className="timeline-controls">
- <PlayButtonContainer/>
- <div className="timeline">
- <div
- className="time-marker"
- style={{left: getXPercentage(currentTick, lastSimulatedTick)}}
- />
- {sectionTicks.map(sectionTick => (
+ render() {
+ return (
+ <div className="timeline-controls">
+ <PlayButtonContainer/>
<div
- key={sectionTick}
- className="section-marker"
- style={{left: getXPercentage(sectionTick, lastSimulatedTick)}}
- />
- ))}
- </div>
- </div>
-);
+ className="timeline"
+ ref={timeline => this.timeline = timeline}
+ onClick={this.onTimelineClick.bind(this)}
+ >
+ <div
+ className="time-marker"
+ style={{left: convertTickToPercentage(this.props.currentTick, this.props.lastSimulatedTick)}}
+ />
+ {this.props.sectionTicks.map(sectionTick => (
+ <div
+ key={sectionTick}
+ className="section-marker"
+ style={{left: convertTickToPercentage(sectionTick, this.props.lastSimulatedTick)}}
+ title="Topology changes at this tick"
+ />
+ ))}
+ </div>
+ </div>
+ );
+ }
+}
export default TimelineControlsComponent;