Browse Source

check if exists

Royi Bernthal 7 years ago
parent
commit
ebab2cbd64
1 changed files with 2 additions and 2 deletions
  1. 2 2
      gui/src/valueAndUnit.ts

+ 2 - 2
gui/src/valueAndUnit.ts

@@ -31,8 +31,8 @@ module BABYLON.GUI {
 
         public getValue(host: AdvancedDynamicTexture): number {
             if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
-                var width: number = (this._value * host.getSize().width) / host.idealWidth;
-                var height: number = (this._value * host.getSize().height) / host.idealHeight;
+                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;
 
                 if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) return window.innerWidth < window.innerHeight ? width : height;
                 if (host.idealWidth) return width; // horizontal