diff options
author | Florrie <towerofnix@gmail.com> | 2017-09-02 13:04:17 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2017-09-02 13:04:17 -0300 |
commit | 8d9cd7b216dafa8a18e481c31b6f2ec9af6faaab (patch) | |
tree | 354e29d8b51d26cbe1fe2eccea428957ee981a90 /src/pickers2.js | |
parent | 3c3084aab308685f03a0546f9e46d143106283a6 (diff) |
Skip back/forwards
Diffstat (limited to 'src/pickers2.js')
-rw-r--r-- | src/pickers2.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/pickers2.js b/src/pickers2.js index e36d257..af3fc2a 100644 --- a/src/pickers2.js +++ b/src/pickers2.js @@ -52,13 +52,28 @@ class HistoryController { } } - getNextTrack() { + getNextTrack(move = true) { // Moves the timeline index forwards and returns the track at the new index // (while refilling the timeline, so that the "up next" list is still full, // and so the picker is called if there is no track at the current index). - this.timelineIndex++ - this.fillTimeline() - return this.currentTrack + if (move) { + this.timelineIndex++ + this.fillTimeline() + return this.currentTrack + } else { + return this.timeline[this.timelineIndex + 1] + } + } + + getBackTrack(move = true) { + if (move) { + if (this.timelineIndex > 0) { + this.timelineIndex-- + } + return this.currentTrack + } else { + return this.timeline[Math.max(this.timelineIndex - 1, 0)] + } } get currentTrack() { |