This commit is contained in:
Timothy Jaeryang Baek committed 2026-08-30 17:44:39 -04:00
1 parent 492ccf3ac0
commit b356b80f8c
2 files changed
+14 -4

No files matched your search

+7 -2
View File
@@ -386,6 +386,10 @@
void selectPage(selectedPage + (e.key === 'ArrowUp' || e.key === 'ArrowLeft' ? -1 : 1)); void selectPage(selectedPage + (e.key === 'ArrowUp' || e.key === 'ArrowLeft' ? -1 : 1));
}; };
const focusViewer = () => {
if (!outerContainer?.contains(document.activeElement)) outerContainer?.focus();
};
const loadPdf = async () => { const loadPdf = async () => {
if (!url && !data) return; if (!url && !data) return;
@@ -462,8 +466,6 @@
}); });
</script> </script>
<svelte:window on:keydown={handleKeyDown} />
<div class="relative {className}"> <div class="relative {className}">
{#if loading} {#if loading}
<div class="absolute inset-0 flex items-center justify-center"> <div class="absolute inset-0 flex items-center justify-center">
@@ -480,8 +482,11 @@
? 'overflow-hidden h-full flex items-center justify-center overscroll-contain' ? 'overflow-hidden h-full flex items-center justify-center overscroll-contain'
: 'overflow-y-auto h-full'} : 'overflow-y-auto h-full'}
bind:this={outerContainer} bind:this={outerContainer}
tabindex="0"
on:scroll={handleScroll} on:scroll={handleScroll}
on:wheel|nonpassive={handleWheel} on:wheel|nonpassive={handleWheel}
on:pointerdown={focusViewer}
on:keydown={handleKeyDown}
> >
<div bind:this={sceneElement} class={singlePage ? '' : 'w-full'}></div> <div bind:this={sceneElement} class={singlePage ? '' : 'w-full'}></div>
</div> </div>
+7 -2
View File
@@ -121,6 +121,10 @@
} }
}; };
const focusPreview = () => {
if (!rootEl?.contains(document.activeElement)) rootEl?.focus();
};
const zoomIn = () => { const zoomIn = () => {
if (!pzInstance || !stageEl) return; if (!pzInstance || !stageEl) return;
pzInstance.zoomTo(stageEl.clientWidth / 2, stageEl.clientHeight / 2, 1.25); pzInstance.zoomTo(stageEl.clientWidth / 2, stageEl.clientHeight / 2, 1.25);
@@ -227,10 +231,11 @@
}); });
</script> </script>
<svelte:window on:keydown={handleKeyDown} />
<div <div
bind:this={rootEl} bind:this={rootEl}
tabindex="0"
on:keydown={handleKeyDown}
on:pointerdown={focusPreview}
class="relative grid {hideThumbs class="relative grid {hideThumbs
? 'grid-cols-[minmax(0,1fr)]' ? 'grid-cols-[minmax(0,1fr)]'
: 'grid-cols-[144px_minmax(0,1fr)]'} min-h-0 bg-transparent text-gray-900 dark:text-gray-100 {className}" : 'grid-cols-[144px_minmax(0,1fr)]'} min-h-0 bg-transparent text-gray-900 dark:text-gray-100 {className}"