preload carousel images
This commit is contained in:
parent
e2f17af6d7
commit
e94b3ab157
@ -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"
|
||||
</IfModule>
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user