This post is a part 16 of Intel XDK Complete Tutorial post series.
Viewport height and width of the application on same device changes according to the orientation of the app. Therefore we will first need to detect the orientation and then find the height and width of the viewport. Height and width is measured in pixels.
if (intel.xdk.device.orientation == "90" || intel.xdk.device.orientation == "-90")
{
//landscape
var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
}
else
{
//portrait
var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
}
{
//landscape
var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
}
else
{
//portrait
var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
}
Learn more on orientation at Guide to Intel XDK Orientation.
Leave a Reply