]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fixed ugly white space while loading file thumbnail
authorVincent Petry <pvince81@owncloud.com>
Tue, 22 Oct 2013 10:08:05 +0000 (12:08 +0200)
committerVincent Petry <pvince81@owncloud.com>
Tue, 22 Oct 2013 10:08:05 +0000 (12:08 +0200)
Preview images are now pre-loaded before being set on the file element.

This fixes #5135 and prevents a white space to be displayed while the
thumbnails is being loaded.

apps/files/js/files.js

index c3a8d81b50d60836dd3e3b3068c72b01c7eaf528..ec2dc7c62ead07f6677c779451a3be487dc44aee 100644 (file)
@@ -663,8 +663,16 @@ function lazyLoadPreview(path, mime, ready, width, height) {
                $.get(previewURL, function() {
                        previewURL = previewURL.replace('(', '%28');
                        previewURL = previewURL.replace(')', '%29');
-                       //set preview thumbnail URL
-                       ready(previewURL + '&reload=true');
+                       previewURL += '&reload=true';
+
+                       // preload image to prevent delay
+                       // this will make the browser cache the image
+                       var img = new Image();
+                       img.onload = function(){
+                               //set preview thumbnail URL
+                               ready(previewURL);
+                       }
+                       img.src = previewURL;
                });
        });
 }