width / 3 }}
on:swipeStart={onSwipeStart}
diff --git a/src/lib/util/functions.test.ts b/src/lib/util/functions.test.ts
deleted file mode 100644
index a4e0028..0000000
--- a/src/lib/util/functions.test.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import { test, expect } from "vitest";
-import { arrMoveMulti } from "./functions";
-
-const ARR = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
-test.each([
- {
- name: "single fwd",
- positions: [1],
- target: 3,
- result: [0, 2, 1, 3, 4, 5, 6, 7, 8, 9],
- offset: -1,
- },
- {
- name: "range fwd",
- positions: [1, 2, 3],
- target: 7,
- result: [0, 4, 5, 6, 1, 2, 3, 7, 8, 9],
- offset: -3,
- },
- {
- name: "range+single fwd",
- positions: [1, 2, 3, 7],
- target: 9,
- result: [0, 4, 5, 6, 8, 1, 2, 3, 7, 9],
- offset: -4,
- },
- {
- name: "single bck",
- positions: [8],
- target: 1,
- result: [0, 8, 1, 2, 3, 4, 5, 6, 7, 9],
- offset: 0,
- },
- {
- name: "range bck",
- positions: [6, 7, 8],
- target: 1,
- result: [0, 6, 7, 8, 1, 2, 3, 4, 5, 9],
- offset: 0,
- },
- {
- name: "range+single bck",
- positions: [8, 3, 6, 7],
- target: 1,
- result: [0, 3, 6, 7, 8, 1, 2, 4, 5, 9],
- offset: 0,
- },
- {
- name: "range inside", // no items get moved
- positions: [2, 3, 4, 5],
- target: 4,
- result: ARR,
- offset: -2,
- },
-])("arrMoveMulti $name", ({ positions, target, result, offset }) => {
- const arr = [...ARR];
-
- const o = arrMoveMulti(arr, positions, target);
-
- expect(arr).toStrictEqual(result);
- expect(o).toBe(offset);
-});
diff --git a/src/lib/util/functions.ts b/src/lib/util/functions.ts
index 20a309c..877a336 100644
--- a/src/lib/util/functions.ts
+++ b/src/lib/util/functions.ts
@@ -236,12 +236,8 @@ export function arrMove
(arr: T[], oldIndex: number, newIndex: number) {
arr.splice(newIndex > oldIndex ? newIndex - 1 : newIndex, 0, ...items);
}
-/** Move a list of items in an array to the target position.
- *
- * Returns the offset of the move operation
- * (the number of positions the items were shifted to the right) */
-export function arrMoveMulti(arr: T[], positions: number[], target: number): number {
- positions.sort((a, b) => a - b);
+export function arrMoveMulti(arr: T[], positions: number[], target: number) {
+ positions.sort();
const toInsert = [];
let offset = 0;
@@ -251,8 +247,33 @@ export function arrMoveMulti(arr: T[], positions: number[], target: number):
}
toInsert.reverse();
arr.splice(target + offset, 0, ...toInsert);
+}
- return offset;
+export function arrMoveMulti2(
+ arr: T[],
+ positions: number[],
+ target: number
+): { array: T[]; offset: number } {
+ const a1 = [],
+ spliced = [];
+ const pset = new Set(positions);
+
+ let offset = 0;
+
+ for (let i = positions.length - 1; i >= 0; i--) {
+ if (target > positions[i]) offset--;
+ }
+
+ for (let i = 0; i < arr.length; i++) {
+ if (pset.has(i)) {
+ spliced.push(arr[i]);
+ } else {
+ a1.push(arr[i]);
+ }
+ }
+
+ a1.splice(target + offset, 0, ...spliced);
+ return { array: a1, offset };
}
export function setCookie(cName: string, cValue: string, expDays: number) {
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index ed9ab96..97c5a2a 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -25,13 +25,12 @@
headerColor,
} from "$lib/stores/layout";
import { clamp, getEventCoords } from "$lib/util/functions";
- import { WIDTH_PHONE, WIDTH_SMALL } from "$lib/util/constants";
+ import { WIDTH_SMALL } from "$lib/util/constants";
- import Navbar from "$lib/components/nav/Navbar.svelte";
+ import Menubar from "$lib/components/nav/Navbar.svelte";
import Playerbar from "$lib/components/player/Playerbar.svelte";
import DummyText from "$lib/components/ui/DummyText.svelte";
import NavbarMobile from "$lib/components/nav/NavbarMobile.svelte";
- import NavbarMobileLandscape from "$lib/components/nav/NavbarMobileLandscape.svelte";
import PlayerbarMobile from "$lib/components/player/PlayerbarMobile.svelte";
import FixedHeader from "$lib/components/header/FixedHeader.svelte";
@@ -54,10 +53,8 @@
let queuebarElm: HTMLElement;
let queuebarResizing = false;
- let mobileLandscape = false;
- $: mobileLandscape = $screenHeight < WIDTH_PHONE && $screenWidth > WIDTH_PHONE;
let showNavbar = false;
- $: showNavbar = $screenWidth >= WIDTH_SMALL && !mobileLandscape;
+ $: showNavbar = $screenWidth >= WIDTH_SMALL;
let showQueue = false;
$: showQueue = showNavbar && $clientState.showQueue;
@@ -171,8 +168,7 @@
-
-
- {:else if mobileLandscape}
-
{/if}
{#if showQueue}
@@ -222,15 +214,15 @@
{/if}
- {#if !showNavbar && !mobileLandscape}
-
+ {#if !showNavbar}
+
{/if}
{/if}
@@ -250,10 +242,6 @@
"main-content" calc(100vh - 3rem)
"player" 3rem / 1fr;
}
-
- &.mobile-landscape {
- grid-template: "main-content" 100vh;
- }
}
#main-content {
@@ -265,10 +253,6 @@
);
}
- .mobile-landscape > #main-content {
- grid-template: "sidebar main" 1fr/10rem 1fr;
- }
-
main {
grid-area: main;
diff --git a/src/routes/playlist/[id]/+page.svelte b/src/routes/playlist/[id]/+page.svelte
index 58a578b..d6b9ff8 100644
--- a/src/routes/playlist/[id]/+page.svelte
+++ b/src/routes/playlist/[id]/+page.svelte
@@ -3,7 +3,7 @@
import type { PageData } from "./$types";
import { searchTerm } from "$lib/stores/layout";
- import { userLink } from "$lib/util/functions";
+ import { userLink, arrMoveMulti, arrMoveMulti2 } from "$lib/util/functions";
import { ListView, type MoveData } from "$lib/util/types";
import { testPlaylist } from "$lib/util/testdata";
// import testPlaylist from "$lib/util/testdata/playlist_5K_conv.json";