Skip to content

Instantly share code, notes, and snippets.

@psflannery
Created October 15, 2013 09:04
Show Gist options
  • Save psflannery/6988794 to your computer and use it in GitHub Desktop.
Save psflannery/6988794 to your computer and use it in GitHub Desktop.
jQuery(document).ready(function($) {
//capture ipad device change
function doOnOrientationChange()
{
switch(window.orientation)
{
case -90:
case 90:
alert('landscape'); //debug
////add class to assist with libraries like Modernizr
$('html').removeClass('portrait').addClass('landscape');
break;
default:
alert('portrait'); //debug
$('html').removeClass('landscape').addClass('portrait');
break;
}
}
//setup event listener
window.addEventListener('orientationchange', doOnOrientationChange);
//initial call
doOnOrientationChange();
});
/* styles for tablet only */
@media (min-width: 768px) and (max-width: 1024px) {
.portrait {
/* styles for ipad landscape orientation */
}
.landscape {
/* styles for ipad landscape orientation */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment