1
0

preload carousel images

This commit is contained in:
Mike Schwörer 2018-02-10 13:01:54 +01:00
parent e2f17af6d7
commit e94b3ab157
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 28 additions and 0 deletions

View File

@ -4,5 +4,8 @@ ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week" ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/gif "access plus 1 week" ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/png "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" ExpiresByType image/svg+xml "access plus 1 day"
</IfModule> </IfModule>

View File

@ -47,6 +47,7 @@ function imgcarousel_init() {
} }
imgcarousel_move(carousel, 0); imgcarousel_move(carousel, 0);
imgcarousel_preload(carousel);
} }
} }
@ -72,5 +73,29 @@ function imgcarousel_move(source, delta) {
content.setAttribute('style', 'background-image: url(' + img + ');'); content.setAttribute('style', 'background-image: url(' + img + ');');
content.innerHTML = ''; 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);
} }