<script>
(function() {
  var SECTION_ID = '698f3a907946c12a586d81fe';

  function patchIframe() {
    var section = document.querySelector('[data-section-id="' + SECTION_ID + '"]');
    if (!section) return;
    var iframe = section.querySelector('.sqs-video-background iframe');
    if (!iframe) return;

    var container = iframe.closest('.sqs-video-background');
    var containerW = container ? container.offsetWidth : window.innerWidth;
    var containerH = container ? container.offsetHeight : window.innerHeight;

    var videoRatio = 9 / 16;
    var neededW = containerH * videoRatio;
    var scale = containerW / neededW;
    var newW = containerW * scale * 1.05;
    var newH = newW * (16 / 9);
    var newLeft = (containerW - newW) / 2;
    var newTop = (containerH - newH) / 2;

    iframe.style.setProperty('width', newW + 'px', 'important');
    iframe.style.setProperty('height', newH + 'px', 'important');
    iframe.style.setProperty('left', newLeft + 'px', 'important');
    iframe.style.setProperty('top', newTop + 'px', 'important');
    iframe.style.setProperty('inset', 'auto', 'important');
    iframe.style.setProperty('position', 'absolute', 'important');
  }

  function init() {
    patchIframe();

    var section = document.querySelector('[data-section-id="' + SECTION_ID + '"]');
    if (!section) return;

    var observer = new MutationObserver(function(mutations) {
      mutations.forEach(function(m) {
        if (m.target.tagName === 'IFRAME') {
          patchIframe();
        }
      });
    });

    observer.observe(section, {
      attributes: true,
      subtree: true,
      attributeFilter: ['style']
    });

    window.addEventListener('resize', patchIframe);
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', init);
  } else {
    init();
  }

  window.addEventListener('mercury:load', function() {
    setTimeout(init, 300);
  });
})();
</script>

 

Buy me a coffee