Royi Bernthal 7 gadi atpakaļ
vecāks
revīzija
0a537ae081
1 mainītis faili ar 21 papildinājumiem un 5 dzēšanām
  1. 21 5
      gui/src/valueAndUnit.ts

+ 21 - 5
gui/src/valueAndUnit.ts

@@ -31,12 +31,28 @@ module BABYLON.GUI {
 
         public getValue(host: AdvancedDynamicTexture): number {
             if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
-                var width: number = host.idealWidth ? (this._value * host.getSize().width) / host.idealWidth : 0;
-                var height: number = host.idealHeight ? (this._value * host.getSize().height) / host.idealHeight : 0;
+                var width: number = 0;
+                var height: number = 0;
 
-                if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) return window.innerWidth < window.innerHeight ? width : height;
-                if (host.idealWidth) return width; // horizontal
-                if (host.idealHeight) return height; // vertical
+                if (host.idealWidth) {
+                    width = (this._value * host.getSize().width) / host.idealWidth;
+                }
+                
+                if (host.idealHeight) {
+                    height = (this._value * host.getSize().height) / host.idealHeight;
+                }
+
+                if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
+                    return window.innerWidth < window.innerHeight ? width : height;
+                }
+
+                if (host.idealWidth) { // horizontal
+                    return width;
+                }
+                
+                if (host.idealHeight) { // vertical
+                    return height;
+                }
             }
             return this._value;
         }