Selaa lähdekoodia

Adjust the viewport

customisations
alemart 10 kuukautta sitten
vanhempi
commit
dc72aa3517
1 muutettua tiedostoa jossa 6 lisäystä ja 4 poistoa
  1. 6
    4
      src/core/viewport.ts

+ 6
- 4
src/core/viewport.ts Näytä tiedosto

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

Loading…
Peruuta
Tallenna