[READ-ONLY] Mirror of https://github.com/probablykasper/kadium. App for staying ontop of YouTube channels' uploads kadium.kasper.space
linux macos notifications tauri windows youtube
0

Configure Feed

Select the types of activity you want to include in your feed.

Keep Left/Right selection at same row

Kasper (Feb 26, 2022, 4:59 AM +0100) bd717f92 8d7aea9f

+16 -11
+16 -11
src/routes/Videos.svelte
··· 127 127 function openChannel(index: number) { 128 128 shell.open('https://www.youtube.com/channel/' + videos[index].channelId) 129 129 } 130 + function getColumnCount() { 131 + const gridStyle = window.getComputedStyle(grid) 132 + const gridTemplateCols = gridStyle.getPropertyValue('grid-template-columns') 133 + return gridTemplateCols.split(' ').length 134 + } 130 135 131 136 function keydown(e: KeyboardEvent) { 132 137 let target = e.target as HTMLElement ··· 136 141 137 142 if (selectionVisible) { 138 143 if (checkShortcut(e, 'ArrowLeft')) { 139 - selectedIndex-- 140 - selectedIndex = Math.max(0, selectedIndex) 141 - e.preventDefault() 144 + if (selectedIndex % getColumnCount() !== 0) { 145 + selectedIndex-- 146 + selectedIndex = Math.max(0, selectedIndex) 147 + e.preventDefault() 148 + } 142 149 } else if (checkShortcut(e, 'ArrowRight')) { 143 - selectedIndex++ 144 - selectedIndex = Math.min(selectedIndex, videos.length - 1) 150 + if ((selectedIndex + 1) % getColumnCount() !== 0) { 151 + selectedIndex++ 152 + selectedIndex = Math.min(selectedIndex, videos.length - 1) 153 + } 145 154 e.preventDefault() 146 155 } else if (checkShortcut(e, 'ArrowUp')) { 147 - const gridStyle = window.getComputedStyle(grid) 148 - const gridTemplateCols = gridStyle.getPropertyValue('grid-template-columns') 149 - const columnCount = gridTemplateCols.split(' ').length 156 + const columnCount = getColumnCount() 150 157 if (selectedIndex - columnCount >= 0) { 151 158 selectedIndex -= columnCount 152 159 } 153 160 e.preventDefault() 154 161 } else if (checkShortcut(e, 'ArrowDown')) { 155 - const gridStyle = window.getComputedStyle(grid) 156 - const gridTemplateCols = gridStyle.getPropertyValue('grid-template-columns') 157 - const columnCount = gridTemplateCols.split(' ').length 162 + const columnCount = getColumnCount() 158 163 if (selectedIndex + columnCount <= videos.length - 1) { 159 164 selectedIndex += columnCount 160 165 }