Skip to content

Instantly share code, notes, and snippets.

@peterwilsoncc
Created December 12, 2011 04:22
Show Gist options
  • Save peterwilsoncc/1464848 to your computer and use it in GitHub Desktop.
Save peterwilsoncc/1464848 to your computer and use it in GitHub Desktop.
"Responsive" lightbox -- requires jQuery & fancybox
<html>
<head>
<title>blah</title>
</head>
<body>
<header> ... </header>
<section>... </section>
<footer> ... </footer>
<div id="responsiveChecks"></div>
</body>
</html>
$(window).ready(function(){
$(window).trigger('resize');
}).resize(function(){
checkSize();
});
function checkSize() {
var $check = $('#responsiveChecks'),
screenSize = $check.position().left * -1;
if (screenSize == 960) {
//setup fancybox
$('a.lightbox').fancybox({});
}
else {
$('a.lightbox').unbind('click.fb');
}
}
/*
allows size checking to be based on what the css reckons.
*/
#responsiveChecks {
position: absolute;
width: 1px;
height:1px;
top:0;
left: -320px;
}
@media all and (min-width:480px) {
#responsiveChecks {
left: -480px;
}
}
@media all and (min-width:760px) {
#responsiveChecks {
left: -760px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment