diff --git a/react-components/src/architecture/base/renderTarget/UnitSystem.ts b/react-components/src/architecture/base/renderTarget/UnitSystem.ts index 889f3abb879..28250c2cd47 100644 --- a/react-components/src/architecture/base/renderTarget/UnitSystem.ts +++ b/react-components/src/architecture/base/renderTarget/UnitSystem.ts @@ -36,6 +36,20 @@ export class UnitSystem { return value; } + public convertFromUnit(value: number, quantity: Quantity): number { + if (!this.isMetric) { + switch (quantity) { + case Quantity.Length: + return value / METER_TO_FT; + case Quantity.Area: + return value / (METER_TO_FT * METER_TO_FT); + case Quantity.Volume: + return value / (METER_TO_FT * METER_TO_FT * METER_TO_FT); + } + } + return value; + } + // ================================================== // INSTANCE METHODS: Convert number to string // ================================================== diff --git a/react-components/src/architecture/concrete/primitives/box/BoxDragger.ts b/react-components/src/architecture/concrete/primitives/box/BoxDragger.ts index cc76f6848ad..5e886740301 100644 --- a/react-components/src/architecture/concrete/primitives/box/BoxDragger.ts +++ b/react-components/src/architecture/concrete/primitives/box/BoxDragger.ts @@ -201,8 +201,9 @@ export class BoxDragger extends BaseDragger { const newSize = this._unitSystem.convertToUnit(size.getComponent(index), Quantity.Length); // Divide the box into abound some parts and use that as the increment const increment = roundIncrement(newSize / 25); - const roundedNewSize = round(newSize, increment); - size.setComponent(index, round(newSize, roundedNewSize)); + let roundedNewSize = round(newSize, increment); + roundedNewSize = this._unitSystem.convertFromUnit(roundedNewSize, Quantity.Length); + size.setComponent(index, roundedNewSize); } if (size.getComponent(index) === this._sizeOfBox.getComponent(index)) { return false; // Nothing has changed