Skip to content

Commit

Permalink
Move autoplay logic to the right location
Browse files Browse the repository at this point in the history
  • Loading branch information
mokimo committed Sep 9, 2024
1 parent 253feca commit ff57508
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions libs/blocks/figure/figure.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function htmlToElement(html) {
function decorateVideo(clone, figEl) {
const videoTag = clone.querySelector('video');
const anchorTag = clone.querySelector('a[href*=".mp4"]');
if(!anchorTag?.hash) anchorTag?.hash = '#autoplay';
if (anchorTag) turnAnchorIntoVideo({ src: anchorTag.href, anchorTag });
if (videoTag) {
videoTag.removeAttribute('data-mouseevent');
Expand Down
3 changes: 1 addition & 2 deletions libs/utils/decorate.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,8 @@ export function decorateMultiViewport(el) {
}

export function turnAnchorIntoVideo({ src, anchorTag }) {
if (anchorTag.closest('.marquee, .aside, .hero-marquee') && !anchorTag.hash) anchorTag.hash = '#autoplay';
const { dataset, parentElement } = anchorTag;
const videoLink = anchorTag.querySelector('a[href*=".mp4"]');
if (videoLink && !videoLink.hash) videoLink.hash = 'autoplay';
const attrs = getVideoAttrs(anchorTag.hash, dataset);
const video = `<video ${attrs} data-video-source=${src}></video>`;
anchorTag.insertAdjacentHTML('afterend', video);
Expand Down

0 comments on commit ff57508

Please sign in to comment.