Skip to content

Commit

Permalink
chore: change video embed loaded to trigger on iframe load event
Browse files Browse the repository at this point in the history
  • Loading branch information
shsteimer committed May 7, 2024
1 parent 6b650dc commit 765cb81
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions blocks/video/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,17 @@ const loadVideoEmbed = (block, link, autoplay, background) => {
const isVimeo = link.includes('vimeo');

if (isYoutube) {
block.append(embedYoutube(url, autoplay, background));
block.dataset.embedIsLoaded = true;
const embedWrapper = embedYoutube(url, autoplay, background);
block.append(embedWrapper);
embedWrapper.querySelector('iframe').addEventListener('load', () => {
block.dataset.embedIsLoaded = true;
});
} else if (isVimeo) {
block.append(embedVimeo(url, autoplay, background));
block.dataset.embedIsLoaded = true;
const embedWrapper = embedVimeo(url, autoplay, background);
block.append(embedWrapper);
embedWrapper.querySelector('iframe').addEventListener('load', () => {
block.dataset.embedIsLoaded = true;
});
} else {
const videoEl = getVideoElement(link, autoplay, background);
block.append(videoEl);
Expand Down

0 comments on commit 765cb81

Please sign in to comment.