ソースを参照

Adjust the viewport

customisations
alemart 10ヶ月前
コミット
dc72aa3517
1個のファイルの変更6行の追加4行の削除
  1. 6
    4
      src/core/viewport.ts

+ 6
- 4
src/core/viewport.ts ファイルの表示

@@ -561,7 +561,7 @@ class ViewportResizer
561 561
      * Trigger a resize event after a delay
562 562
      * @param delay in milliseconds
563 563
      */
564
-    triggerResize(delay: number = 50): void
564
+    triggerResize(delay: number = 100): void
565 565
     {
566 566
         const event = new ViewportEvent('resize');
567 567
 
@@ -733,22 +733,24 @@ class BestFitResizeStrategy extends ImmersiveResizeStrategy
733 733
         const subContainer = viewport._subContainer;
734 734
         const windowAspectRatio = window.innerWidth / window.innerHeight;
735 735
         const viewportAspectRatio = viewport._realSize.width / viewport._realSize.height;
736
-        let width = 1, height = 1;
736
+        let width = 1, height = 1, left = '0px', top = '0px';
737 737
 
738 738
         if(viewportAspectRatio <= windowAspectRatio) {
739 739
             height = window.innerHeight;
740 740
             width = Math.round(height * viewportAspectRatio);
741 741
             width -= width % 2;
742
+            left = `calc(50% - ${width >>> 1}px)`;
742 743
         }
743 744
         else {
744 745
             width = window.innerWidth;
745 746
             height = Math.round(width / viewportAspectRatio);
746 747
             height -= height % 2;
748
+            top = `calc(50% - ${height >>> 1}px)`;
747 749
         }
748 750
 
749 751
         subContainer.style.position = 'absolute';
750
-        subContainer.style.left = `calc(50% - ${width >>> 1}px)`;
751
-        subContainer.style.top = `calc(50% - ${height >>> 1}px)`;
752
+        subContainer.style.left = left;
753
+        subContainer.style.top = top;
752 754
         subContainer.style.width = width + 'px';
753 755
         subContainer.style.height = height + 'px';
754 756
 

読み込み中…
キャンセル
保存