Fixed #26: can now reorder tracks in queue using drag and drop

This commit is contained in:
Eliot Berriot 2017-06-28 19:34:05 +02:00
parent 03bb740db3
commit 33eecf55cb
3 changed files with 49 additions and 23 deletions

View file

@ -92,6 +92,24 @@ class Queue {
}
cache.set('volume', newValue)
}
reorder (oldIndex, newIndex) {
// called when the user uses drag / drop to reorder
// tracks in queue
if (oldIndex === this.currentIndex) {
this.currentIndex = newIndex
return
}
if (oldIndex < this.currentIndex && newIndex >= this.currentIndex) {
// item before was moved after
this.currentIndex -= 1
}
if (oldIndex > this.currentIndex && newIndex <= this.currentIndex) {
// item after was moved before
this.currentIndex += 1
}
}
append (track, index) {
this.previousQueue = null
index = index || this.tracks.length