From e94b3ab1578f3d427721153d2bfb2e4b61dd5162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sat, 10 Feb 2018 13:01:54 +0100 Subject: [PATCH] preload carousel images --- www/data/images/.htaccess | 3 +++ www/data/javascript/ms_basic.js | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/www/data/images/.htaccess b/www/data/images/.htaccess index 3835eb5..81f86ca 100644 --- a/www/data/images/.htaccess +++ b/www/data/images/.htaccess @@ -4,5 +4,8 @@ ExpiresByType image/jpg "access plus 1 week" ExpiresByType image/jpeg "access plus 1 week" ExpiresByType image/gif "access plus 1 week" ExpiresByType image/png "access plus 1 week" +ExpiresByType video/webm "access plus 1 week" +ExpiresByType video/mp4 "access plus 1 week" +ExpiresByType video/ogg "access plus 1 week" ExpiresByType image/svg+xml "access plus 1 day" \ No newline at end of file diff --git a/www/data/javascript/ms_basic.js b/www/data/javascript/ms_basic.js index d0458e5..ab81e1f 100644 --- a/www/data/javascript/ms_basic.js +++ b/www/data/javascript/ms_basic.js @@ -47,6 +47,7 @@ function imgcarousel_init() { } imgcarousel_move(carousel, 0); + imgcarousel_preload(carousel); } } @@ -72,5 +73,29 @@ function imgcarousel_move(source, delta) { content.setAttribute('style', 'background-image: url(' + img + ');'); content.innerHTML = ''; } +} +function imgcarousel_preload(source) { + let carousel = findParent(source, ".imgcarousel_parent"); //
+ let images = JSON.parse(carousel.getAttribute('data-imgcarousel-images')); + + setTimeout(function () { + let preload_img = []; + + let i = 0; + for (let img of images) + { + if (img.toLowerCase().endsWith('.webm')) + { + // ??? + } + else + { + preload_img[i] = new Image(); + preload_img[i].src = img; + i++; + } + } + + }, 1000); } \ No newline at end of file