1
0

preload carousel images

This commit is contained in:
2018-02-10 13:01:54 +01:00
parent e2f17af6d7
commit e94b3ab157
2 changed files with 28 additions and 0 deletions

View File

@@ -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"); // <div>
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);
}