Merge pull request #127 from RedFlagRF/master

修复PDF懒加载判断错误导致渲染多余不存在canvas问题
This commit is contained in:
hit757 2023-08-24 13:38:32 +08:00 committed by GitHub
commit eda8ab8283
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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