瀏覽代碼

load the preview-images only when needed

Raanan Weber 5 年之前
父節點
當前提交
1fc7fb9af2
共有 2 個文件被更改,包括 6 次插入1 次删除
  1. 5 0
      Playground/js/examples.js
  2. 1 1
      Playground/js/main.js

+ 5 - 0
Playground/js/examples.js

@@ -85,6 +85,11 @@ class Examples {
 
         this.fpsLabel.style.display = 'none';
         this.toggleExamplesButtons.call(this, true);
+        this.exampleList.querySelectorAll("img").forEach(function(img) {
+            if(!img.src) {
+                img.src = img.getAttribute("data-src");
+            }
+        })
     };
 
     /**

+ 1 - 1
Playground/js/main.js

@@ -548,7 +548,7 @@ class Main {
                                 example.id = ii;
 
                                 var exampleImg = document.createElement("img");
-                                exampleImg.src = this.scripts[i].samples[ii].icon.replace("icons", "https://doc.babylonjs.com/examples/icons");
+                                exampleImg.setAttribute("data-src", this.scripts[i].samples[ii].icon.replace("icons", "https://doc.babylonjs.com/examples/icons"));
                                 exampleImg.setAttribute("onClick", "document.getElementById('PGLink_" + this.scripts[i].samples[ii].PGID + "').click();");
 
                                 var exampleContent = document.createElement("div");