using
window.addEventListener('deviceorientation', handleOrientation);
to listen for device orientation
I know I need to find the alpha of device (0 - 360) but don't know what range to use to find out if the phone is in landscape mode
using
window.addEventListener('deviceorientation', handleOrientation);
to listen for device orientation
I know I need to find the alpha of device (0 - 360) but don't know what range to use to find out if the phone is in landscape mode
You should check the alpha value from the event.
function handleOrientation (event) {
if (event.alpha>89 && event.alpha<150) {//the device is landscape at 90
console.log("Device is landscape");
};
}