Skip to content

Instantly share code, notes, and snippets.

@buritica
Created June 4, 2014 20:57
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 buritica/113c6a5ab103d80f6a1b to your computer and use it in GitHub Desktop.
Save buritica/113c6a5ab103d80f6a1b to your computer and use it in GitHub Desktop.
Celtra orientation detection for Onswipe
function getDocDimensions() {
var D = window.parent.parent.document;
return [
D.documentElement.clientWidth,
D.documentElement.clientHeight
];
}
function getOrientation() {
var dimensions = getDocDimensions();
console.log('dimensions', dimensions);
if (dimensions[0] > dimensions[1]) {
return 'Landscape';
} else {
return 'Portrait';
}
}
function setCreativeOrientation(orientation) {
var adScreen = unit.find(orientation);
unit.goToScreenAction(ctx, {screen: adScreen}, c);
}
var orientation = getOrientation();
setCreativeOrientation(orientation);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment