Browse Source

优化打印时载入动画的展示策略

sunyj 8 years ago
parent
commit
5bdc10778a
1 changed files with 3 additions and 3 deletions
  1. 3 3
      src/main/webapp/resources/js/preview/app.js

+ 3 - 3
src/main/webapp/resources/js/preview/app.js

@@ -189,6 +189,7 @@ function loadData() {
 				document.getElementById('pageSize').textContent = pageSize;
 				renderPage(pageIndex);
 				if (printType == "PRINT") {
+					spinner = showLoading(spinner, spinnerContainer);
 					setTimeout("printPdf()", 1000);
 				}
 			});
@@ -214,9 +215,6 @@ function renderPage(pageIndex) {
 	if (!pdfDoc) {
 		return;
 	}
-	if (printType == "PRINT") {
-		spinner = showLoading(spinner, spinnerContainer);
-	}
 	pdfDoc.getPage(pageIndex).then(function(page) {
 		if (!scale || scale == "auto") {
 			// 调整为适合的宽度
@@ -299,6 +297,7 @@ function nextPage() {
  * 打印
  */
 function printPdf() {
+	// 先隐藏可能在显示的动画,如果可打印,之后再重新(必须)显示
 	spinner = hideLoading(spinner);
 	if (!pdfDoc) {
 		return;
@@ -333,6 +332,7 @@ function checkBrowser() {
 	console.log(userAgent);
 	if (userAgent.indexOf("Chrome") == -1 || userAgent.indexOf("Edge") !== -1) {
 		alert(spinnerContainer, "建议使用最新版Chrome浏览器打印");
+		spinner = hideLoading(spinner);
 	}
 }