Visual Console Client: Improved the color cloud resizing
Former-commit-id: 4f6131a8368ea1af973527388ed641f104381fe6
This commit is contained in:
parent
b0052577a4
commit
850045f791
|
@ -63,9 +63,8 @@ export default class ColorCloud extends VisualConsoleItem<ColorCloudProps> {
|
|||
const gradientId = `grad_${this.props.id}`;
|
||||
// SVG container.
|
||||
const svg = document.createElementNS(svgNS, "svg");
|
||||
// Resize SVG. Use only the width, cause this element only needs a diameter.
|
||||
svg.setAttribute("width", `${this.props.width}px`);
|
||||
svg.setAttribute("height", `${this.props.width}px`);
|
||||
// Auto resize SVG using the view box magic: https://css-tricks.com/scale-svg/
|
||||
svg.setAttribute("viewBox", "0 0 100 100");
|
||||
|
||||
// Defs.
|
||||
const defs = document.createElementNS(svgNS, "defs");
|
||||
|
@ -104,22 +103,4 @@ export default class ColorCloud extends VisualConsoleItem<ColorCloudProps> {
|
|||
|
||||
return svg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override VisualConsoleItem.resize
|
||||
* To resize the item.
|
||||
* @param diameter Diameter.
|
||||
*/
|
||||
public resize(diameter: number): void {
|
||||
// Resize parent. Use the diameter as width and height.
|
||||
super.resize(diameter, diameter);
|
||||
|
||||
// Get SVG element.
|
||||
const svgElement = this.elementRef.getElementsByTagName("svg").item(0);
|
||||
if (svgElement === null) return;
|
||||
|
||||
// Resize SVG. Use only the width, cause this element only needs a diameter.
|
||||
svgElement.setAttribute("width", `${this.props.width}px`);
|
||||
svgElement.setAttribute("height", `${this.props.width}px`);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue