Link in components

This commit is contained in:
Cmdr McDonald
2017-03-11 13:28:24 +00:00
parent 6f67267fec
commit 067b69f449
7 changed files with 276 additions and 20 deletions

View File

@@ -58,12 +58,14 @@ export default class Cargo extends TranslatedComponent {
*/
_cargoChange(cargoLevel) {
const { cargoCapacity } = this.state;
// We round the cargo level to a suitable value given the capacity
cargoLevel = Math.round(cargoLevel * cargoCapacity) / cargoCapacity;
if (cargoCapacity > 0) {
// We round the cargo level to a suitable value given the capacity
cargoLevel = Math.round(cargoLevel * cargoCapacity) / cargoCapacity;
if (cargoLevel != this.state.cargoLevel) {
this.setState({ cargoLevel });
this.props.onChange(Math.round(cargoLevel * cargoCapacity));
if (cargoLevel != this.state.cargoLevel) {
this.setState({ cargoLevel });
this.props.onChange(Math.round(cargoLevel * cargoCapacity));
}
}
}