Always show the motor value regardless if it's 0. (#509)

This commit is contained in:
Sam El-Husseini 2018-04-13 14:01:25 -07:00 committed by GitHub
parent 4bcde58c0c
commit 7f8499bb5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,6 @@ namespace pxsim.visuals {
if (!motorState) return; if (!motorState) return;
const speed = motorState.getSpeed(); const speed = motorState.getSpeed();
if (!speed) return;
this.setMotorAngle(motorState.getAngle() % 360); this.setMotorAngle(motorState.getAngle() % 360);
this.setMotorLabel(speed); this.setMotorLabel(speed);
} }
@ -42,13 +41,8 @@ namespace pxsim.visuals {
this.motorLabelGroup = pxsim.svg.child(this.content, "g") as SVGGElement; this.motorLabelGroup = pxsim.svg.child(this.content, "g") as SVGGElement;
this.motorLabel = pxsim.svg.child(this.motorLabelGroup, "text", { 'text-anchor': 'middle', 'x': '0', 'y': '0', 'class': 'sim-text number inverted' }) as SVGTextElement; this.motorLabel = pxsim.svg.child(this.motorLabelGroup, "text", { 'text-anchor': 'middle', 'x': '0', 'y': '0', 'class': 'sim-text number inverted' }) as SVGTextElement;
} }
// If Motor speed is not 0
if (this.currentLabel) {
this.motorLabel.textContent = `${this.currentLabel}%`; this.motorLabel.textContent = `${this.currentLabel}%`;
this.positionMotorLabel(); this.positionMotorLabel();
} else {
this.motorLabel.textContent = ``;
}
} }
protected abstract positionMotorLabel(): void; protected abstract positionMotorLabel(): void;