Medium motor resizing (#472)

This commit is contained in:
Sam El-Husseini 2018-04-09 16:24:01 -07:00 committed by GitHub
parent ac1380ec92
commit b8286ab0b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -13,7 +13,11 @@ namespace pxsim.visuals {
}
public getPaddingRatio() {
return 1 / 5;
return 1 / 8;
}
getWiringRatio() {
return 0.5;
}
protected renderMotorAngle(holeEl: Element, angle: number) {

View File

@ -75,7 +75,7 @@ namespace pxsim.visuals {
return 0;
}
if (!this.content.hasAttribute("viewBox")) {
return parseFloat(this.content.getAttribute("height"));
return this.getContentHeight();
}
return parseFloat(this.content.getAttribute("viewBox").split(" ")[3]);
}
@ -85,11 +85,25 @@ namespace pxsim.visuals {
return 0;
}
if (!this.content.hasAttribute("viewBox")) {
return parseFloat(this.content.getAttribute("width"));
return this.getContentWidth();
}
return parseFloat(this.content.getAttribute("viewBox").split(" ")[2]);
}
public getContentHeight() {
if (!this.content) {
return 0;
}
return parseFloat(this.content.getAttribute("height"));
}
public getContentWidth() {
if (!this.content) {
return 0;
}
return parseFloat(this.content.getAttribute("width"));
}
public attachEvents() {
}
@ -98,7 +112,7 @@ namespace pxsim.visuals {
this.updateDimensions(width, height);
}
private updateDimensions(width: number, height: number) {
protected updateDimensions(width: number, height: number) {
if (this.content) {
const currentWidth = this.getInnerWidth();
const currentHeight = this.getInnerHeight();