Skip to content

Commit efca86b

Browse files
committed
fixed spread
1 parent f2ab834 commit efca86b

3 files changed

Lines changed: 39 additions & 33 deletions

File tree

src/lib/PDFPluginLoader.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
fullscreen = useFullscreen();
4646
print = usePrint(() => documentId);
4747
zoom = useZoom(() => documentId);
48-
//spread = useSpread(() => documentId);
48+
spread = useSpread(() => documentId);
4949
</script>
5050

5151
<span></span>

src/lib/PDFViewer.svelte

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import {
1111
Scroller,
1212
ScrollPluginPackage,
13+
ScrollStrategy,
1314
type RenderPageProps
1415
} from '@embedpdf/plugin-scroll/svelte';
1516
import {
@@ -54,16 +55,18 @@
5455
initialDocuments: [{ url: asset('using-lemniscate-editor.pdf') }]
5556
}),
5657
createPluginRegistration(ViewportPluginPackage),
57-
createPluginRegistration(ScrollPluginPackage),
58+
createPluginRegistration(ScrollPluginPackage, {
59+
defaultStrategy: ScrollStrategy.Vertical
60+
}),
5861
createPluginRegistration(RenderPluginPackage),
5962
createPluginRegistration(PrintPluginPackage),
6063
createPluginRegistration(ExportPluginPackage),
6164
createPluginRegistration(ZoomPluginPackage, {
6265
defaultZoomLevel: ZoomMode.FitPage,
6366
}),
64-
/*createPluginRegistration(SpreadPluginPackage, {
67+
createPluginRegistration(SpreadPluginPackage, {
6568
defaultSpreadMode: SpreadMode.None
66-
}),*/
69+
}),
6770
createPluginRegistration(FullscreenPluginPackage),
6871
createPluginRegistration(TilingPluginPackage, {
6972
tileSize: 768,
@@ -129,36 +132,37 @@
129132
<DocumentContent {documentId}>
130133
{#snippet children(documentContent)}
131134
{#if documentContent.isLoaded}
132-
{#snippet renderPage(page: RenderPageProps)}
133135
<div
134-
style:width='{page.width}px'
135-
style:height='{page.height}px'
136+
style:width='100%'
137+
style:height='100%'
136138
style:position='relative'
137139
>
138-
<RenderLayer
139-
{documentId}
140-
pageIndex={page.pageIndex}
141-
scale={1.0}
142-
/>
143-
<TilingLayer
144-
{documentId}
145-
pageIndex={page.pageIndex}
146-
/>
140+
<Viewport {documentId} style={$SettingsStore.theme === 'dark' ? 'background-color:#2E3235' : 'background-color:#FFFFFF'}>
141+
<Scroller {documentId}>
142+
{#snippet renderPage(page: RenderPageProps)}
143+
<RenderLayer
144+
{documentId}
145+
pageIndex={page.pageIndex}
146+
scale={1.0}
147+
/>
148+
<TilingLayer
149+
{documentId}
150+
pageIndex={page.pageIndex}
151+
/>
152+
{/snippet}
153+
</Scroller>
154+
<PDFPluginLoader
155+
bind:activeDocument
156+
bind:docManager
157+
bind:exportApi
158+
bind:fullscreen
159+
bind:print
160+
bind:spread
161+
bind:zoom
162+
{documentId}
163+
/>
164+
</Viewport>
147165
</div>
148-
{/snippet}
149-
<PDFPluginLoader
150-
bind:activeDocument
151-
bind:docManager
152-
bind:exportApi
153-
bind:fullscreen
154-
bind:print
155-
bind:spread
156-
bind:zoom
157-
{documentId}
158-
/>
159-
<Viewport {documentId} style={$SettingsStore.theme === 'dark' ? 'background-color:#2E3235' : 'background-color:#FFFFFF'}>
160-
<Scroller {documentId} {renderPage} />
161-
</Viewport>
162166
{/if}
163167
{/snippet}
164168
</DocumentContent>

src/routes/+page.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
tooltipText='View Editor Only'
214214
on:click={() => {
215215
panelVisibility = 'editor';
216-
//pdfview.spreadPdf(false);
216+
pdfview.spreadPdf(false);
217217
}}
218218
>
219219
<RightPanelClose />
@@ -222,7 +222,8 @@
222222
tooltipText='View Split Screen'
223223
on:click={() => {
224224
panelVisibility = 'split';
225-
//pdfview.spreadPdf(false);
225+
pdfview.spreadPdf(false);
226+
pdfview.zoomPdf('fit')
226227
}}
227228
>
228229
<SplitScreen />
@@ -231,7 +232,8 @@
231232
tooltipText='View PDF Only'
232233
on:click={() => {
233234
panelVisibility = 'pdfviewer';
234-
//pdfview.spreadPdf(true);
235+
pdfview.spreadPdf(true);
236+
pdfview.zoomPdf('fit')
235237
}}
236238
>
237239
<SidePanelClose />

0 commit comments

Comments
 (0)