diginext-utils
Version:
README.md
39 lines (38 loc) • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.requestDeviceOrientationControl = void 0;
const device_1 = require("../device");
const requestDeviceOrientationControl = () => {
if (typeof window == "undefined")
return false;
return new Promise((resolve, reject) => {
if ((0, device_1.isAndroid)())
resolve(true);
if (typeof DeviceMotionEvent != "undefined" && DeviceMotionEvent.requestPermission) {
// (optional) Do something before API request prompt.
DeviceMotionEvent
.requestPermission()
.then((response) => {
// (optional) Do something after API prompt dismissed.
if (response == "granted") {
resolve(true);
// resolve({ status: true })
}
else {
resolve(false);
// resolve({ status: false, reason: "DeviceMotionEvent is not support" })
}
})
.catch((response) => {
resolve(false);
// resolve({ status: false, reason: response })
});
}
else {
resolve(false);
// resolve({ status: false, reason: "DeviceMotionEvent is not defined" })
}
});
};
exports.requestDeviceOrientationControl = requestDeviceOrientationControl;
exports.default = exports.requestDeviceOrientationControl;