Add 'web/app/themes/badegg/' from commit 'b31aa7550b02a4516fdf161f53dc7666854c9a14'
git-subtree-dir: web/app/themes/badegg git-subtree-mainline:b862ff9755git-subtree-split:b31aa7550b
This commit is contained in:
24
web/app/themes/badegg/resources/js/lib/VideoSrcset.js
Normal file
24
web/app/themes/badegg/resources/js/lib/VideoSrcset.js
Normal file
@@ -0,0 +1,24 @@
|
||||
export default function VideoSrcset( element )
|
||||
{
|
||||
const sizes = JSON.parse(element.dataset.sizes);
|
||||
|
||||
Object.keys(sizes).forEach((key) => {
|
||||
const size = key;
|
||||
const source = element.querySelector('.bgvid-' + size);
|
||||
|
||||
if(source) {
|
||||
const sourceWidth = source.dataset.width;
|
||||
const poster = source.dataset.poster;
|
||||
|
||||
if(window.innerWidth >= sourceWidth) {
|
||||
console.log('screen width is greater than or equal to the source width');
|
||||
console.log('screen width: ' + window.innerWidth);
|
||||
console.log('source width: ' + sourceWidth);
|
||||
|
||||
element.src = source.src;
|
||||
element.poster = poster;
|
||||
element.load;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user