refac
This commit is contained in:
1 parent
492ccf3ac0
commit
b356b80f8c
2 files changed
+29
-19
No files matched your search
@@ -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,9 +466,7 @@
|
|||||||
});
|
});
|
||||||
</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">
|
||||||
<Spinner className="size-5" />
|
<Spinner className="size-5" />
|
||||||
@@ -475,14 +477,17 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class={singlePage
|
class={singlePage
|
||||||
? '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}
|
||||||
on:scroll={handleScroll}
|
tabindex="0"
|
||||||
on:wheel|nonpassive={handleWheel}
|
on:scroll={handleScroll}
|
||||||
>
|
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>
|
||||||
|
|
||||||
|
|||||||
@@ -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,14 +231,15 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:keydown={handleKeyDown} />
|
<div
|
||||||
|
bind:this={rootEl}
|
||||||
<div
|
tabindex="0"
|
||||||
bind:this={rootEl}
|
on:keydown={handleKeyDown}
|
||||||
class="relative grid {hideThumbs
|
on:pointerdown={focusPreview}
|
||||||
? 'grid-cols-[minmax(0,1fr)]'
|
class="relative grid {hideThumbs
|
||||||
: 'grid-cols-[144px_minmax(0,1fr)]'} min-h-0 bg-transparent text-gray-900 dark:text-gray-100 {className}"
|
? 'grid-cols-[minmax(0,1fr)]'
|
||||||
>
|
: 'grid-cols-[144px_minmax(0,1fr)]'} min-h-0 bg-transparent text-gray-900 dark:text-gray-100 {className}"
|
||||||
|
>
|
||||||
<aside
|
<aside
|
||||||
class={hideThumbs
|
class={hideThumbs
|
||||||
? 'hidden'
|
? 'hidden'
|
||||||
|
|||||||
Reference in new issue
Block a user