Skip to content

Commit 3ebbe1e

Browse files
committed
feat: 🎸 increase zoom capability
1 parent e01c672 commit 3ebbe1e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

react-pdf/Reader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Reader extends React.Component<Props, State> {
5353
error: undefined,
5454
}
5555

56-
MAX_SCALE = 2
56+
MAX_SCALE = 4
5757
__zoomEvent = false
5858

5959
onDocumentLoadSuccess = ({ numPages }) => {

src/bundleContainer.ts

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

src/index.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export interface Props {
5252
useGoogleReader?: boolean
5353
withScroll?: boolean
5454
withPinchZoom?: boolean
55+
maximumPinchZoomScale?: number
5556
onLoad?(event: WebViewNavigationEvent): void
5657
onLoadEnd?(event: WebViewNavigationEvent | WebViewErrorEvent): void
5758
onError?(event: WebViewErrorEvent | WebViewHttpErrorEvent | string): void
@@ -70,6 +71,7 @@ function viewerHtml(
7071
customStyle?: CustomStyle,
7172
withScroll: boolean = false,
7273
withPinchZoom: boolean = false,
74+
maximumPinchZoomScale: number = 5,
7375
): string {
7476
return `
7577
<!DOCTYPE html>
@@ -78,7 +80,7 @@ function viewerHtml(
7880
<title>PDF reader</title>
7981
<meta charset="utf-8" />
8082
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, maximum-scale=${
81-
withPinchZoom ? '4.0' : '1.0'
83+
withPinchZoom ? `${maximumPinchZoomScale}.0` : '1.0'
8284
}, user-scalable=${withPinchZoom ? 'yes' : 'no'}" />
8385
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/pdf.min.js"></script>
8486
<script src="https://cdn.jsdelivr.net/npm/[email protected]/web/pdf_viewer.min.js"></script>
@@ -129,6 +131,7 @@ async function writeWebViewReaderFileAsync(
129131
customStyle?: CustomStyle,
130132
withScroll?: boolean,
131133
withPinchZoom?: boolean,
134+
maximumPinchZoomScale?: number,
132135
): Promise<void> {
133136
const { exists, md5 } = await getInfoAsync(bundleJsPath, { md5: true })
134137
const bundleContainer = require('./bundleContainer')
@@ -137,7 +140,13 @@ async function writeWebViewReaderFileAsync(
137140
}
138141
await writeAsStringAsync(
139142
htmlPath,
140-
viewerHtml(data, customStyle, withScroll, withPinchZoom),
143+
viewerHtml(
144+
data,
145+
customStyle,
146+
withScroll,
147+
withPinchZoom,
148+
maximumPinchZoomScale,
149+
),
141150
)
142151
}
143152

@@ -276,7 +285,7 @@ class PdfReader extends React.Component<Props, State> {
276285

277286
init = async () => {
278287
try {
279-
const { source, customStyle, withScroll, withPinchZoom } = this.props
288+
const { source, customStyle, withScroll, withPinchZoom, } = this.props
280289
const { renderType } = this.state
281290
switch (renderType!) {
282291
case 'URL_TO_BASE64': {

0 commit comments

Comments
 (0)