Skip to content

Commit

Permalink
Increase zoom range, add background color and slight box-shadow (elev…
Browse files Browse the repository at this point in the history
…ation) to the PDF viewer's viewport
  • Loading branch information
MHShetty committed Aug 11, 2021
1 parent c1e2b20 commit 8f5919a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
12 changes: 12 additions & 0 deletions app/src/main/assets/viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,15 @@ body, canvas, #padding {
.textLayer .endOfContent.active {
top: 0px;
}

#content {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;

width: 100%;
height: 100%;
}
2 changes: 1 addition & 1 deletion app/src/main/assets/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function renderPage(pageNumber, zoom, prerender, prerenderTrigger=0) {
return;
}

const viewport = page.getViewport({scale: newZoomRatio, rotation: orientationDegrees})
const viewport = page.getViewport({scale: window.screen.width / page.getViewport({scale: 1}).width * newZoomRatio, rotation: orientationDegrees})

if (useRender) {
if (newZoomRatio !== zoomRatio) {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/org/grapheneos/pdfviewer/PdfViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
"usb 'none'; " +
"vr 'none'";

private static final float MIN_ZOOM_RATIO = 0.5f;
private static final float MAX_ZOOM_RATIO = 1.5f;
private static final float MIN_ZOOM_RATIO = 0.9f;
private static final float MAX_ZOOM_RATIO = 3f;
private static final int ALPHA_LOW = 130;
private static final int ALPHA_HIGH = 255;
private static final int ACTION_OPEN_DOCUMENT_REQUEST_CODE = 1;
Expand All @@ -88,7 +88,7 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
private Uri mUri;
public int mPage;
public int mNumPages;
private float mZoomRatio = 1f;
private float mZoomRatio = MIN_ZOOM_RATIO;
private int mDocumentOrientationDegrees;
private int mDocumentState;
private int windowInsetTop;
Expand Down

0 comments on commit 8f5919a

Please sign in to comment.