Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoKam committed May 22, 2024
2 parents 9e67b03 + 04f99bc commit bffd26d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-clocks-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@orca-fe/pdf-viewer': patch
---

fix: 缩小时,调整页码的位置不对的 bug
4 changes: 3 additions & 1 deletion packages/pdf-viewer/src/PDFViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,10 @@ const PDFViewer = React.forwardRef<PDFViewerHandle, PDFViewerProps>((props, pRef
const dom = pageContainerRef.current;
if (dom) {
const top = pageTopArr[page];
const height = viewports[page]?.height * scale * PixelsPerInch.PDF_TO_CSS_UNITS;
const containerHeight = dom.getBoundingClientRect().height;
dom.scrollTo({
top,
top: Math.min(top, top + 0.5 * (height - containerHeight)),
behavior: anim ? 'smooth' : 'auto',
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ const ZoomAndPageController = (props: ZoomAndPageControllerProps) => {
}
}}
onChange={(value) => {
if (!Number.isNaN(Number(value) - 1)) {
pdfViewer.changePage(Number(value) - 1);
const newPage = Number(value) - 1;
if (!Number.isNaN(newPage) && pdfViewer.getCurrentPage() !== newPage) {
pdfViewer.changePage(newPage);
}
}}
/>
Expand Down

0 comments on commit bffd26d

Please sign in to comment.