Browse Source

make sure event type exists

Raanan Weber 5 năm trước cách đây
mục cha
commit
55ab068ab4
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  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') {