fix: 修复PDF组件在PDF页面超过默认懒加载页数时。在滚动页面时,由于判断错误,导致计算numPages 值比实际页数大,且未经判断,直接渲染新页面导致。使得渲染后的页面出现了什么都没有canvas

This commit is contained in:
追逐者 2023-08-24 12:13:58 +08:00 committed by GitHub
parent ab3f8bb444
commit e790ed9c18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,11 +78,14 @@ export default defineComponent({
function onScrollPdf(e) {
const { scrollTop, scrollHeight, clientHeight } = e.target;
if (scrollTop + clientHeight >= scrollHeight) {
if (numPages.value < pdfDocument.numPages) {
let oldNum = numPages.value;
numPages.value += Math.min(lazySize, pdfDocument.numPages);
renderPage(oldNum+1);
}
if (numPages.value >= pdfDocument.numPages) {
return;
}
let oldNum = numPages.value;
numPages.value = Math.min(pdfDocument.numPages, oldNum + lazySize);
if (numPages.value > oldNum) {
renderPage(oldNum + 1);
}
}
}