diff --git a/CHANGELOG.md b/CHANGELOG.md index 31925c6..8a9d5f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Next - Load 100 videos at a time instead of 50 +- Allow selecting bottom row diagonally with the down arrow key ## 1.5.0 - 2023 Nov 19 - Add support for all channel URLs. URLs like `/lacunarecs`, `/@lacunarecs`, `/c/lacunarecs`, `/user/lacunarecs` and even `/lacunarecs/playlists` etc work now. diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index c55fec6..3f2a95f 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -53,7 +53,7 @@ await autoloadHandler() } async function autoloadHandler() { - if (!allLoaded && isScrolledToBottom() && !loading) { + if (!allLoaded && isScrolledNearBottom() && !loading) { await getMoreVideos() } } @@ -99,7 +99,7 @@ } let scrollDiv: HTMLElement | null = null - function isScrolledToBottom() { + function isScrolledNearBottom() { if (scrollDiv) { const lastElement = boxes[videos.length - 1] const threshold = lastElement.offsetTop - 200 @@ -159,9 +159,8 @@ e.preventDefault() } else if (checkShortcut(e, 'ArrowDown')) { const columnCount = getColumnCount() - if (selectedIndex + columnCount <= videos.length - 1) { - selectedIndex += columnCount - } + selectedIndex += columnCount + selectedIndex = Math.min(selectedIndex, videos.length - 1) e.preventDefault() } else if (checkShortcut(e, 'Escape')) { selectionVisible = false