浏览代码

make sure event type exists

Raanan Weber 5 年之前
父节点
当前提交
55ab068ab4
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/Cameras/Inputs/freeCameraDeviceOrientationInput.ts

+ 2 - 2
src/Cameras/Inputs/freeCameraDeviceOrientationInput.ts

@@ -75,7 +75,7 @@ export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera
                 }, timeout);
             }
 
-            if (typeof (<any>DeviceOrientationEvent).requestPermission === 'function') {
+            if (typeof(DeviceOrientationEvent) !== "undefined" && typeof (<any>DeviceOrientationEvent).requestPermission === 'function') {
                 (<any>DeviceOrientationEvent).requestPermission()
                     .then((response: string) => {
                         if (response == 'granted') {
@@ -143,7 +143,7 @@ export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera
                 //So this is needed.
                 this._orientationChanged();
             };
-            if (typeof (<any>DeviceOrientationEvent).requestPermission === 'function') {
+            if (typeof(DeviceOrientationEvent) !== "undefined" && typeof (<any>DeviceOrientationEvent).requestPermission === 'function') {
                 (<any>DeviceOrientationEvent).requestPermission()
                     .then((response: string) => {
                         if (response === 'granted') {