mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 06:59:24 +02:00
Fixed #26: can now reorder tracks in queue using drag and drop
This commit is contained in:
parent
03bb740db3
commit
33eecf55cb
3 changed files with 49 additions and 23 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue