mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-30 12:16:07 +01:00
fix (pdf): pdf on small device
whenever using a phone with no native PDF support, we'd render 2 page in a row making things not visible
This commit is contained in:
parent
1609747f55
commit
fb4c6200ba
1 changed files with 6 additions and 2 deletions
|
|
@ -53,7 +53,7 @@ async function ctrlPDFJs(render) {
|
|||
render($page);
|
||||
|
||||
const $container = qs($page, `[data-bind="pdf"]`);
|
||||
const createBr = () => $container.appendChild(document.createElement("br"));
|
||||
const createBr = () => $container.appendChild(createElement(`<div style="height:${document.body.clientWidth > 600 ? 20 : 5}px"> </div>`));
|
||||
const removeLoader = createLoader($container);
|
||||
const base = qs(document.head, "base").getAttribute("href");
|
||||
effect(rxjs.from(window.pdfjsLib.getDocument(base + getDownloadUrl()).promise).pipe(
|
||||
|
|
@ -62,9 +62,13 @@ async function ctrlPDFJs(render) {
|
|||
createBr();
|
||||
for (let i=0; i<pdf.numPages; i++) {
|
||||
const page = await pdf.getPage(i + 1);
|
||||
const marginLeftRight = (document.body.clientWidth > 600 ? 50 : 15);
|
||||
const viewport = page.getViewport({
|
||||
scale: Math.min(
|
||||
Math.max(document.body.clientWidth - 200, 0),
|
||||
Math.max(
|
||||
document.body.clientWidth - marginLeftRight,
|
||||
0,
|
||||
),
|
||||
800,
|
||||
) / page.getViewport({ scale: 1 }).width,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue