Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make queue items moveable via drag & drop #185

Merged
merged 10 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
"solid-js": "^1.8.17"
},
"devDependencies": {
"@netlify/edge-functions": "^2.8.1",
"@netlify/edge-functions": "^2.6.1",
"@types/sortablejs": "^1.15.8",
"autoprefixer": "^10.4.19",
"eruda": "^3.0.1",
"sortablejs": "^1.15.2"
"typescript": "^5.4.5",
"vite": "^5.2.12",
"vite-plugin-pwa": "^0.20.0",
Expand Down
3 changes: 1 addition & 2 deletions src/components/StreamItem.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
margin-bottom: 2dvmin;
border: var(--border);
border-radius: calc(var(--roundness) + 0.75vmin);
transition: transform 0.2s ease-out;
display: flex;
align-items: center;
justify-content: space-between;
Expand Down Expand Up @@ -92,4 +91,4 @@

}

}
}
15 changes: 10 additions & 5 deletions src/scripts/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { queuelist, upcomingBtn } from "../lib/dom";
import player from "../lib/player";
import StreamItem from "../components/StreamItem";
import { render } from "solid-js/web";
// import Sortable from "sortablejs";
import Sortable, { SortableEvent } from "sortablejs";

const queueArray: string[] = [];

Expand Down Expand Up @@ -51,8 +51,13 @@ export function appendToQueuelist(data: DOMStringMap, prepend: boolean = false)

}


//new Sortable(queuelist, {});
new Sortable(queuelist, {
handle: '.ri-draggable',
onUpdate(e: SortableEvent) {
if (e.oldIndex == null || e.newIndex == null) return;
queueArray.splice(e.newIndex, 0, queueArray.splice(e.oldIndex, 1)[0]);
}
});

queuelist.addEventListener('click', e => {

Expand All @@ -69,7 +74,9 @@ queuelist.addEventListener('click', e => {

const index = queueArray.indexOf(id);


queueArray.splice(index, 1);

queuelist.children[index].remove();
});

Expand Down Expand Up @@ -171,5 +178,3 @@ new MutationObserver(m => {
}
}
}).observe(queuelist, { childList: true });