Last active
August 29, 2015 14:25
-
-
Save rochow/da3326f6cbe6a92d605f to your computer and use it in GitHub Desktop.
jQuery - Fancybox with Ratio
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
// Set the height of the video based on the width & ratio of the video | |
// That way even on mobile devices fancybox will be the size of the video and not have blank space | |
$( window ).resize( function() { | |
var _ratio = 0.56; | |
var _maxWidth = 1500; | |
var _width = $(window).width() - 50; | |
if( _width > _max) { | |
_width = _max; | |
} | |
var _height = _width * _ratio; | |
$( '.play' ).fancybox({ | |
openEffect : 'none', | |
closeEffect : 'none', | |
padding : 0, | |
height : _height, | |
width : _width, | |
helpers : { | |
media : {} | |
} | |
}); | |
}).resize(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment