Browse Source

Adjust the best-fit size of the immersive viewport

customisations
alemart 1 year ago
parent
commit
34b23a468d
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      src/core/viewport.ts

+ 6
- 4
src/core/viewport.ts View File

653
 
653
 
654
         if(viewportAspectRatio <= windowAspectRatio) {
654
         if(viewportAspectRatio <= windowAspectRatio) {
655
             height = window.innerHeight;
655
             height = window.innerHeight;
656
-            width = (height * viewportAspectRatio) | 0;
656
+            width = Math.round(height * viewportAspectRatio);
657
+            width -= width % 2;
657
         }
658
         }
658
         else {
659
         else {
659
             width = window.innerWidth;
660
             width = window.innerWidth;
660
-            height = (width / viewportAspectRatio) | 0;
661
+            height = Math.round(width / viewportAspectRatio);
662
+            height -= height % 2;
661
         }
663
         }
662
 
664
 
663
         subContainer.style.position = 'absolute';
665
         subContainer.style.position = 'absolute';
664
-        subContainer.style.left = `calc(50% - ${(width+1) >>> 1}px)`;
665
-        subContainer.style.top = `calc(50% - ${(height+1) >>> 1}px)`;
666
+        subContainer.style.left = `calc(50% - ${width >>> 1}px)`;
667
+        subContainer.style.top = `calc(50% - ${height >>> 1}px)`;
666
         subContainer.style.width = width + 'px';
668
         subContainer.style.width = width + 'px';
667
         subContainer.style.height = height + 'px';
669
         subContainer.style.height = height + 'px';
668
 
670
 

Loading…
Cancel
Save