From 691dbed54e57873f6ff25aec01c7b95242a7bead Mon Sep 17 00:00:00 2001 From: Kam <331677620@qq.com> Date: Tue, 5 Sep 2023 17:58:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=BE=A9=E9=BB=98=E8=AA=8D?= =?UTF-8?q?=E6=94=B9=E5=8B=95=E7=B8=AE=E6=94=BE=E6=AF=94=E5=BE=8C=EF=BC=8C?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E4=BD=8D=E7=BD=AE=E8=AD=98=E5=88=A5=E5=87=BA?= =?UTF-8?q?=E7=8F=BE=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/pdf-viewer/CHANGELOG.md | 6 ++++++ packages/pdf-viewer/package.json | 2 +- packages/pdf-viewer/src/PDFViewer.tsx | 8 +++++--- pnpm-lock.yaml | 28 +++++++++++++-------------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/packages/pdf-viewer/CHANGELOG.md b/packages/pdf-viewer/CHANGELOG.md index d52669d5..820f63dc 100644 --- a/packages/pdf-viewer/CHANGELOG.md +++ b/packages/pdf-viewer/CHANGELOG.md @@ -1,5 +1,11 @@ # @orca-fe/pdf-viewer +## 1.19.2 + +### Patch Changes + +- fix: 修復默認改動縮放比後,渲染位置識別出現問題 + ## 1.19.1 ### Patch Changes diff --git a/packages/pdf-viewer/package.json b/packages/pdf-viewer/package.json index f55e1d71..804c3344 100644 --- a/packages/pdf-viewer/package.json +++ b/packages/pdf-viewer/package.json @@ -1,6 +1,6 @@ { "name": "@orca-fe/pdf-viewer", - "version": "1.19.1", + "version": "1.19.2", "description": "PDF Viewer", "keywords": [ "react", diff --git a/packages/pdf-viewer/src/PDFViewer.tsx b/packages/pdf-viewer/src/PDFViewer.tsx index 665bf00b..76235f55 100644 --- a/packages/pdf-viewer/src/PDFViewer.tsx +++ b/packages/pdf-viewer/src/PDFViewer.tsx @@ -221,7 +221,9 @@ const PDFViewer = React.forwardRef((props, pRef let maxWidth = 0; let pageMaxWidth = 0; let pageMaxHeight = 0; - const topArr = viewports.map(({ height, width }) => { + const topArr = viewports.map(({ height: _height, width: _width }) => { + const width = _width * PixelsPerInch.PDF_TO_CSS_UNITS; + const height = _height * PixelsPerInch.PDF_TO_CSS_UNITS; const _top = top; top += Math.floor(height + pageGap) * scale; maxWidth = Math.max(width * scale, maxWidth); @@ -240,9 +242,9 @@ const PDFViewer = React.forwardRef((props, pRef if (zoomMode && _this.size && maxWidth && pageMaxHeight) { if (zoomMode === 'autoWidth') { // 调整缩放级别,使其与容器宽度匹配 - newZoom = Math.log2((_this.size.width - 32) / PixelsPerInch.PDF_TO_CSS_UNITS / pageMaxWidth); + newZoom = Math.log2((_this.size.width - 32) / pageMaxWidth); } else if (zoomMode === 'autoHeight') { - newZoom = Math.log2((_this.size.height - 32) / PixelsPerInch.PDF_TO_CSS_UNITS / pageMaxHeight); + newZoom = Math.log2((_this.size.height - 32) / pageMaxHeight); } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6620dcc4..402f9012 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,9 +1,5 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - importers: .: @@ -142,13 +138,13 @@ importers: specifier: '>=4.8.0' version: 5.1.3(react-dom@18.2.0)(react@18.2.0) '@orca-fe/hooks': - specifier: ^1.9.0 + specifier: ^1.9.1 version: link:../hooks '@orca-fe/jss-plugin-auto-prefix': specifier: ^0.0.1 version: 0.0.1(jss@10.10.0)(react@18.2.0) '@orca-fe/pocket': - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../pocket '@orca-fe/simple-jss': specifier: ^0.0.3 @@ -279,13 +275,13 @@ importers: specifier: ^4.7.0 version: 4.7.0(react-dom@18.2.0)(react@18.2.0) '@orca-fe/hooks': - specifier: ^1.9.0 + specifier: ^1.9.1 version: link:../hooks '@orca-fe/jss-plugin-auto-prefix': specifier: ^0.0.1 version: 0.0.1(jss@10.10.0)(react@18.2.0) '@orca-fe/pocket': - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../pocket '@orca-fe/simple-jss': specifier: ^0.0.3 @@ -294,7 +290,7 @@ importers: specifier: ^0.10.0 version: link:../tools '@orca-fe/transformer': - specifier: ^0.3.23 + specifier: ^0.3.24 version: link:../transformer ahooks: specifier: ^3.7.8 @@ -334,19 +330,19 @@ importers: specifier: ^4.7.0 version: 4.7.0(react-dom@18.2.0)(react@18.2.0) '@orca-fe/hooks': - specifier: ^1.9.0 + specifier: ^1.9.1 version: link:../hooks '@orca-fe/jss-plugin-auto-prefix': specifier: ^0.0.1 version: 0.0.1(jss@10.10.0)(react@18.2.0) '@orca-fe/painter': - specifier: ^1.4.37 + specifier: ^1.4.38 version: link:../painter '@orca-fe/pdfjs-dist-browserify': specifier: ^3.8.24 version: 3.8.24 '@orca-fe/pocket': - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../pocket '@orca-fe/simple-jss': specifier: ^0.0.3 @@ -401,7 +397,7 @@ importers: specifier: '>=4.7.0' version: 5.1.3(react-dom@18.2.0)(react@17.0.2) '@orca-fe/hooks': - specifier: ^1.9.0 + specifier: ^1.9.1 version: link:../hooks '@orca-fe/jss-plugin-auto-prefix': specifier: ^0.0.1 @@ -516,7 +512,7 @@ importers: packages/transformer: dependencies: '@orca-fe/hooks': - specifier: ^1.9.0 + specifier: ^1.9.1 version: link:../hooks '@orca-fe/jss-plugin-auto-prefix': specifier: ^0.0.1 @@ -17627,3 +17623,7 @@ packages: /zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} dev: false + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false