Guest User

Untitled

a guest
Nov 3rd, 2020
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function setVideoCenter() {
  2.   let $box = $('.slider-menu__slider-img_video');
  3.   let height = $box.height();
  4.   let width = $box.width();
  5.   let new_height = width / 1.78;
  6.   if (new_height > height) {
  7.     $box.find('video').css({
  8.         width: width,
  9.         height: new_height,
  10.         top: '0',
  11.         left: '0',
  12.     });
  13.   } else {
  14.     let new_width = height * 1.78;
  15.     $box.find('video').css({
  16.         width: new_width,
  17.         height: height,
  18.         top: '0',
  19.         left: '-' + (new_width / 2 - width / 2) + 'px'
  20.     });
  21.   }
  22. }
  23.  
  24. $(function(){
  25.     setVideoCenter();
  26.     $(window).resize(setVideoCenter);
  27. });
Advertisement
Add Comment
Please, Sign In to add comment