Skip to content

Commit

Permalink
Scroll to selected item when using arrow keys
Browse files Browse the repository at this point in the history
  • Loading branch information
probablykasper committed Jul 29, 2024
1 parent 0b1d54a commit 6c60282
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Next
- Fix missing property errors
- Ignore destinations without mount point (until a better solution is found)
- Scroll to selected item when using arrow keys

## 1.2.0 - 2023 May 19
- Support macOS 13
Expand Down
15 changes: 13 additions & 2 deletions src/page/Page.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<script lang="ts">
import PageItems from './PageItems.svelte'
import { page, backupInfos, pageMap } from './page'
import { page, backupInfos, pageMap, selectedPath } from './page'
import Button from '../lib/Button.svelte'
import ProgressBar from '../lib/ProgressBar.svelte'
import commands from '../lib/commands'
import type { DestinationDetail } from '../../bindings'
import { tick } from 'svelte'
let content_el: HTMLDivElement
export let destination: DestinationDetail | null = null
async function compare(autoLoad = false) {
Expand All @@ -30,6 +32,15 @@
}
}
}
$: if ($selectedPath) {
tick().then(() => {
console.log('.selected', document.querySelector('.selected'))
content_el
.querySelector('.selected')
?.scrollIntoView({ behavior: 'instant', block: 'nearest', inline: 'nearest' })
})
}
</script>

{#if !destination}
Expand All @@ -43,7 +54,7 @@
{:else}
<main>
<div class="bar">{$page.backup.path}</div>
<div class="content">
<div class="content" bind:this={content_el}>
{#if $page.loading}
<div class="absolute center-align">
<ProgressBar />
Expand Down

0 comments on commit 6c60282

Please sign in to comment.