Преглед изворни кода

Add constants for clarity

customisations
alemart пре 2 месеци
родитељ
комит
1ea7d7c4a4
1 измењених фајлова са 13 додато и 8 уклоњено
  1. 13
    8
      src/core/viewport.ts

+ 13
- 8
src/core/viewport.ts Прегледај датотеку

@@ -109,6 +109,12 @@ const HUD_ZINDEX = BASE_ZINDEX + 2;
109 109
 /** Time in ms used to throttle the resize callback of the window */
110 110
 const RESIZE_THROTTLE_DELAY = 100;
111 111
 
112
+/** Duration in ms of the polling after a change of orientation */
113
+const ORIENTATION_POLLING_DURATION = 500; // 500 ms for iOS
114
+
115
+/** Number of cycles of the polling */
116
+const ORIENTATION_POLLING_CYCLES = 5; // the more cycles, the quicker a cycle is
117
+
112 118
 
113 119
 
114 120
 
@@ -614,7 +620,7 @@ class ViewportResizer
614 620
     }
615 621
 
616 622
     /**
617
-     * Called when a change of screen orientation is detected
623
+     * Called when a change of device orientation is detected
618 624
      */
619 625
     private async _onOrientationChange(): Promise<void>
620 626
     {
@@ -644,16 +650,15 @@ class ViewportResizer
644 650
 
645 651
         */
646 652
 
647
-        const MAX_ATTEMPTS = 3; //5;
648 653
         const canvas = this._viewport._backgroundCanvas;
649 654
 
650
-        for(let i = 0; i < MAX_ATTEMPTS; i++) {
655
+        // this is polling
656
+        for(let i = 0; i < ORIENTATION_POLLING_CYCLES; i++) {
651 657
 
652
-            // this is polling
653
-            await Utils.wait(RESIZE_THROTTLE_DELAY);
658
+            await Utils.wait(ORIENTATION_POLLING_DURATION / ORIENTATION_POLLING_CYCLES);
654 659
 
655
-            // After one delay, this._viewport.aspectRatio will likely be
656
-            // correct, but the canvas will not reflect that if, instants ago,
660
+            // After the camera feed is rotated, this._viewport.aspectRatio will
661
+            // be correct, but the canvas will not reflect that if, instants ago,
657 662
             // it was resized using the previous aspect ratio of the media.
658 663
             const a = canvas.width / canvas.height;
659 664
             const b = this._aspectRatioOfScreen();
@@ -684,7 +689,7 @@ class ViewportResizer
684 689
 
685 690
         If so, increasing the throttling will likely make the camera feed be
686 691
         rotated first, but then the user will more easily notice the delay.
687
-        Increasing MAX_ATTEMPTS is a simple alternative that makes this
692
+        Increasing the polling time is a simple alternative that makes this
688 693
         callback be executed after the video rotation, which is what we want.
689 694
         About listening to video resize: the Viewport doesn't know about it
690 695
         and has no access to the source of data. The Session does, however.

Loading…
Откажи
Сачувај