In this tutorial I will show you how you can lock your Intel XDK apps orientation and also detect the current orientation.
Locking Orientation
intel.xdk.device.setRotateOrientation() function is used to lock orientation.
Lock to “portrait” orientation
Lock to “landscape” orientation
Unlock Orientation
Unlocking the orientation again allows the app to change orientation according to device rotation. intel.xdk.device.setRotateOrientation() function is also used to unlock orientation.
Finding current orientation
intel.xdk.device.orientation property can be used to find the current orientation.
{
//landscape
}
else
{
//portrait
}
Finding Initial Orientation
Initial orientation is the orientation when app was launched. intel.xdk.device.initialOrientation can be used to find the initial orientation.
{
//landscape
}
else
{
//portrait
}
Tracking Orientation Change
Whenever orientation changes intel.xdk.device.orientation.change event is fired.
if (intel.xdk.device.orientation == "90" || intel.xdk.device.orientation == "-90")
{
//landscape
}
else
{
//portrait
}
});