Explorar o código

Merge pull request #301 from fangzhengjin/patch-1

fix: PDF/word图片模式预览时, 下翻图片时频繁请求图片资源
gitchenjh %!s(int64=3) %!d(string=hai) anos
pai
achega
0a5fc1e4a8
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      server/src/main/resources/static/js/lazyload.js

+ 6 - 2
server/src/main/resources/static/js/lazyload.js

@@ -19,8 +19,12 @@ function checkImgs() {
 }
 
 function loadImg(el) {
-    var source = el.getAttribute("data-src");
-    el.src = source;
+    var loaded = el.getAttribute("loaded");
+    if (!Boolean(loaded)) {
+        var source = el.getAttribute("data-src");
+        el.setAttribute("loaded", true);
+        el.src = source;
+    }
 }
 // var mustRun = 500
 // function throttle(fn, mustRun) {