浏览代码

对连续快速翻页进行限制

sunyj 8 年之前
父节点
当前提交
936fe06b84
共有 1 个文件被更改,包括 15 次插入6 次删除
  1. 15 6
      src/main/webapp/resources/js/preview/app.js

+ 15 - 6
src/main/webapp/resources/js/preview/app.js

@@ -30,8 +30,10 @@ var wholePdfPath;
 var pagedPdfPath;
 // 参数打印类型,可能为PRINT、PREVIEW
 var printType = getParameter("printType");
-// 首次加载页面()
+// 首次加载页面
 var firstRequest = true;
+//用于标识是否正在翻页,防止连续快速翻页,影响展示效果
+var paging = false;
 
 // 记录刚加载该页面时的时间
 var startTime = new Date();
@@ -252,6 +254,7 @@ function loadPagedPdf(pagedPdfPath, ifPreloadWholePdf) {
 			.getDocument(pagedPdfPath)
 			.then(
 					function(pdfDoc_) {
+						paging = false;
 						// 更新页码
 						document.getElementById('pageIndex').value = pageIndex;
 						pdfDoc = pdfDoc_;
@@ -476,9 +479,12 @@ function prevPage() {
 	if (timeout()) {
 		return;
 	}
-	// 获取前一页的pdf
-	pageIndex--;
-	loadData(pageIndex);
+	if (!paging) {
+		paging = true;
+		// 获取前一页的pdf
+		pageIndex--;
+		loadData(pageIndex);
+	}
 }
 
 /**
@@ -495,8 +501,11 @@ function nextPage() {
 	if (timeout()) {
 		return;
 	}
-	pageIndex++;
-	loadData(pageIndex);
+	if (!paging) {
+		paging = true;
+		pageIndex++;
+		loadData(pageIndex);
+	}
 }
 
 /**