Bladeren bron

Adjust the best-fit size of the immersive viewport

customisations
alemart 1 jaar geleden
bovenliggende
commit
34b23a468d
1 gewijzigde bestanden met toevoegingen van 6 en 4 verwijderingen
  1. 6
    4
      src/core/viewport.ts

+ 6
- 4
src/core/viewport.ts Bestand weergeven

@@ -653,16 +653,18 @@ class BestFitResizeStrategy extends ImmersiveResizeStrategy
653 653
 
654 654
         if(viewportAspectRatio <= windowAspectRatio) {
655 655
             height = window.innerHeight;
656
-            width = (height * viewportAspectRatio) | 0;
656
+            width = Math.round(height * viewportAspectRatio);
657
+            width -= width % 2;
657 658
         }
658 659
         else {
659 660
             width = window.innerWidth;
660
-            height = (width / viewportAspectRatio) | 0;
661
+            height = Math.round(width / viewportAspectRatio);
662
+            height -= height % 2;
661 663
         }
662 664
 
663 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 668
         subContainer.style.width = width + 'px';
667 669
         subContainer.style.height = height + 'px';
668 670
 

Laden…
Annuleren
Opslaan