Created
July 8, 2016 08:59
-
-
Save al5dy/60214756b9f7130a0f7bf97fc4efc7cf to your computer and use it in GitHub Desktop.
"Размазываем" фоновое видео в зависимости от соотношения сторон
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vimeoSettings : function () { | |
var wa = 16, // Соотношение сторон | |
ha = 9, // Соотношение сторон | |
$videoBlock = $('.vimeo-video'), // Блок внутри которого лежит iframe | |
od = $videoBlock.width()/$videoBlock.height(), | |
vd = wa/ha, | |
nvh = (od/vd)*100, | |
nvw = (vd/od)*100; | |
if (od>vd) | |
$videoBlock.find('iframe').css({height:nvh+'%', width:'100%', top:-(nvh-100)/2+'%',left:'0px',position:'absolute'}); | |
else | |
$videoBlock.find('iframe').css({width:nvw+'%', height:'100%', left:-(nvw-100)/2+'%',top:'0px',position:'absolute'}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also:
vcResizeVideoBackground : function ($element) {