Skip to content

Commit

Permalink
Move the default autoplay for background
Browse files Browse the repository at this point in the history
  • Loading branch information
mokimo committed Sep 9, 2024
1 parent f9c9845 commit 9cb99fa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 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
4 changes: 1 addition & 3 deletions libs/utils/decorate.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ export function handleFocalpoint(pic, child, removeChild) {

export async function decorateBlockBg(block, node, { useHandleFocalpoint = false } = {}) {
const childCount = node.childElementCount;
console.log(block.innerHTML);
const videoLink = block.querySelector('video, a[href*=".mp4"]');
if (videoLink && !videoLink.hash) videoLink.hash = 'autoplay';
if (node.querySelector('img, video, a[href*=".mp4"]') || childCount > 1) {
node.classList.add('background');
const binaryVP = [['mobile-only'], ['tablet-only', 'desktop-only']];
Expand Down Expand Up @@ -311,6 +308,7 @@ 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 attrs = getVideoAttrs(anchorTag.hash, dataset);
const video = `<video ${attrs} data-video-source=${src}></video>`;
Expand Down

0 comments on commit 9cb99fa

Please sign in to comment.