Skip to content

Instantly share code, notes, and snippets.

@rochow
Last active August 29, 2015 14:25
Show Gist options
  • Save rochow/da3326f6cbe6a92d605f to your computer and use it in GitHub Desktop.
Save rochow/da3326f6cbe6a92d605f to your computer and use it in GitHub Desktop.
jQuery - Fancybox with Ratio
// 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