Dispose correctly of gradient definitions in the control. Attach to port number not id.

This commit is contained in:
Sam El-Husseini 2018-04-10 11:49:15 -07:00
parent f41310e879
commit 8398c8efdb
2 changed files with 12 additions and 2 deletions

View File

@ -53,7 +53,7 @@ namespace pxsim.visuals {
getInnerView(parent: SVGSVGElement, globalDefs: SVGDefsElement) {
this.group = svg.elt("g") as SVGGElement;
let gc = "gradient-color";
let gc = "gradient-color-" + this.getPort();
this.colorGradient = svg.linearGradient(globalDefs, gc, false);
svg.setGradientValue(this.colorGradient, "50%");
svg.setGradientColors(this.colorGradient, "black", "yellow");
@ -99,5 +99,10 @@ namespace pxsim.visuals {
return this.group;
}
public dispose() {
if (this.colorGradient) this.colorGradient.parentElement.removeChild(this.colorGradient);
super.dispose();
}
}
}

View File

@ -13,7 +13,7 @@ namespace pxsim.visuals {
private static SLIDER_SIDE_PADDING = 6;
getInnerView(parent: SVGSVGElement, globalDefs: SVGDefsElement) {
let gid = "gradient-slider-" + this.getId();
let gid = "gradient-slider-" + this.getPort();
this.group = svg.elt("g") as SVGGElement;
this.gradient = createGradient(gid, this.getGradientDefinition());
this.gradient.setAttribute('x1', '0%');
@ -74,6 +74,11 @@ namespace pxsim.visuals {
return this.group;
}
public dispose() {
if (this.gradient) this.gradient.parentElement.removeChild(this.gradient);
super.dispose();
}
getInnerHeight() {
return 192;
}