Skip to content

Instantly share code, notes, and snippets.

@dustintheweb
Last active December 17, 2015 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustintheweb/5535310 to your computer and use it in GitHub Desktop.
Save dustintheweb/5535310 to your computer and use it in GitHub Desktop.
Make Colorbox modals responsive
// jquery >> Responsive Colorbox >>>>>>>>>>>>>>>>
(function($){
// -- ColorBox Init --------------------------------------------------------------------------------------------------
var resizeTimer, ct, winWidth = $(window).width();
//
$(window).resize(function(){
if (resizeTimer) ct = clearTimeout(resizeTimer);
resizeTimer = window.setTimeout(function() {
if ($('#cboxOverlay').is(':visible')) {
$.colorbox.load(true);
}
}, 300);
});
//
if (winWidth >= 1024) {
$('.cb-youtube').colorbox({speed:500, opacity:0.5, iframe:true, innerWidth:'80%', innerHeight:'80%', maxWidth:'80%', maxHeight:'80%'});
$('.cb-images').colorbox({rel:'image-group', speed:500, opacity:0.5, innerWidth:'80%', innerHeight:'80%', maxWidth:'80%', maxHeight:'80%'});
} if (winWidth < 1024) {
$('.cb-youtube').colorbox({transition:'fade', speed:500, opacity:0.5, iframe:true, innerWidth:'80%', innerHeight:'50%', maxWidth:'80%', maxHeight:'50%'});
$('.cb-images').colorbox({rel:'image-group', speed:500, opacity:0.5, innerWidth:'80%', innerHeight:'50%', maxWidth:'80%', maxHeight:'50%'});
} // etc...
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment