Files
bedrock/web/app/themes/badegg/resources/js/lib/VideoSrcset.js
Steve Ross 76520e58d2 Add 'web/app/themes/badegg/' from commit '2b425fd2ea8083ef47852429a353e1afc4e93bf8'
git-subtree-dir: web/app/themes/badegg
git-subtree-mainline: 272b0f6525
git-subtree-split: 2b425fd2ea
2025-11-22 17:26:50 +00:00

25 lines
685 B
JavaScript

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;
}
}
});
}