瀏覽代碼

eliminate flicker for live previews

AUTOMATIC 2 年之前
父節點
當前提交
f6aac4c65a
共有 2 個文件被更改,包括 8 次插入7 次删除
  1. 7 7
      javascript/progressbar.js
  2. 1 0
      style.css

+ 7 - 7
javascript/progressbar.js

@@ -184,15 +184,15 @@ function requestProgress(id_task, progressbarContainer, gallery, atEnd, onProgre
 
 
 
 
             if(res.live_preview){
             if(res.live_preview){
+
+                var rect = gallery.getBoundingClientRect()
+                if(rect.width){
+                    livePreview.style.width = rect.width + "px"
+                    livePreview.style.height = rect.height + "px"
+                }
+
                 var img = new Image();
                 var img = new Image();
                 img.onload = function() {
                 img.onload = function() {
-                    var rect = gallery.getBoundingClientRect()
-                    if(rect.width){
-                        livePreview.style.width = rect.width + "px"
-                        livePreview.style.height = rect.height + "px"
-                    }
-
-                    livePreview.innerHTML = ''
                     livePreview.appendChild(img)
                     livePreview.appendChild(img)
                     if(livePreview.childElementCount > 2){
                     if(livePreview.childElementCount > 2){
                         livePreview.removeChild(livePreview.firstElementChild)
                         livePreview.removeChild(livePreview.firstElementChild)

+ 1 - 0
style.css

@@ -338,6 +338,7 @@ input[type="range"]{
 }
 }
 
 
 .livePreview img{
 .livePreview img{
+    position: absolute;
     object-fit: contain;
     object-fit: contain;
     width: 100%;
     width: 100%;
     height: 100%;
     height: 100%;