Last active
August 29, 2015 14:08
-
-
Save salmenbej/4d2f168c88688f51be4f to your computer and use it in GitHub Desktop.
Check the Portrait / Landscape mode on mobile device with ssm.js ( http://www.simplestatemanager.com/ )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssm.addConfigOption({name:"orientation", test: function(){ | |
//landscape mode | |
if(this.state.orientation === "landscape" && window.innerWidth >= window.innerHeight){ | |
console.log('landscape'); | |
return true; | |
} | |
//portrait mode | |
else if (this.state.orientation === "portrait" && window.innerWidth <= window.innerHeight){ | |
console.log('portrait'); | |
return true; | |
} | |
else { | |
return false; | |
} | |
}}); | |
//How to use it | |
ssm.addStates([ | |
{ | |
id: 'tablet', | |
minWidth: 768, | |
maxWidth: 1023, | |
orientation: 'portrait', | |
onEnter: function(){ | |
console.log('enter tablet portrait mode'); | |
} | |
},{ | |
id: 'tablet', | |
minWidth: 768, | |
maxWidth: 1023, | |
orientation: 'landscape', | |
onEnter: function(){ | |
console.log('enter tablet landscape mode'); | |
} | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment