summaryrefslogtreecommitdiff
path: root/src/components/timeline/TimelineControlsComponent.js
blob: 2e093583b209c683ba9d47be631e181d23dc5de3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import React from "react";
import PlayButtonContainer from "../../containers/timeline/PlayButtonContainer";

function getXPercentage(tick, maxTick) {
    if (maxTick === 0) {
        return "0%";
    } else if (tick > maxTick) {
        return ((maxTick / (maxTick + 1)) * 100) + "%";
    }

    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 => (
                <div
                    key={sectionTick}
                    className="section-marker"
                    style={{left: getXPercentage(sectionTick, lastSimulatedTick)}}
                />
            ))}
        </div>
    </div>
);

export default TimelineControlsComponent;