Skip to content

Instantly share code, notes, and snippets.

@leowebguy
Last active February 18, 2020 15:27
Show Gist options
  • Save leowebguy/606ebe34113d6eacb42c0cac0fd70be4 to your computer and use it in GitHub Desktop.
Save leowebguy/606ebe34113d6eacb42c0cac0fd70be4 to your computer and use it in GitHub Desktop.
fancybox + iframe with device size > screen detection and resize.
var width = window.innerWidth;
$(document).ready(function() {
$(".fancybox").fancybox({
beforeShow : function() {
var alt = "Watch more <a href='mypage.html'>videos</a>";
this.title = alt;
},
helpers : {
title: {
type: 'inside',
position: 'bottom'
}
},
//maxWidth: 620,
//maxHeight: 430,
fitToView: true,
width: '100%',
height: '100%',
autoSize: false,
closeClick: false,
openEffect: 'none',
closeEffect: 'none',
overlayColor: '#ddd'
});
if (width <= 479) {
$("a.fancybox").each(function() {
this.href += '?view=phone';
});
$(".fancybox").fancybox({
maxWidth : 310,
maxHeight : 220,
})
} else if (width <= 639) {
$("a.fancybox").each(function() {
this.href += '?view=tablet';
});
$(".fancybox").fancybox({
maxWidth : 465,
maxHeight : 330,
})
} else {
$(".fancybox").fancybox({
maxWidth : 620,
maxHeight : 440,
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment