TheMartes
3/8/2017 - 8:28 PM

This JavaScript is supossed to make video responsive in IE 6+

This JavaScript is supossed to make video responsive in IE 6+

// This JavaScript is supossed to make video responsive in IE 6+
export default function(el) {
  if (isIe()) {
    let videoEl = el.querySelector('video');
    let ration = (1920 / 1080);

    el.classList.add('ie-fix');

    if (dimensions(el).height > (dimensions(videoEl).width / ration)) {
      let newWidth = dimensions(el).height * ration;

      videoEl.style.top = '0';
      videoEl.style.left = '50%';
      videoEl.style.width = newWidth + 'px';
      videoEl.style.marginLeft = ((newWidth / 2) * (-1)) + 'px';
    }
    else if (dimensions(el).width > (dimensions(videoEl).height * ration)) {
      let newHeight = dimensions(el).width / ration;

      videoEl.style.left = '0';
      videoEl.style.top = '50%';
      videoEl.style.height = newHeight + 'px';
      videoEl.style.marginTop = ((newHeight / 2) * (-1)) + 'px';
    }
  }
}