diff --git a/src/components/Roof2.jsx b/src/components/Roof2.jsx index 2d275a36..70deec93 100644 --- a/src/components/Roof2.jsx +++ b/src/components/Roof2.jsx @@ -596,10 +596,13 @@ export default function Roof2(props) { const changeLength = (e) => { setScale(e) const polygon = canvas?.getActiveObject() + if (polygon.type !== 'QPolygon') { return } + polygon.setScaleX(e) + canvas?.renderAll() } diff --git a/src/components/fabric/QPolygon.js b/src/components/fabric/QPolygon.js index a3329ac5..0c503185 100644 --- a/src/components/fabric/QPolygon.js +++ b/src/components/fabric/QPolygon.js @@ -213,7 +213,12 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, { }, setFontSize(fontSize) { this.fontSize = fontSize - this.text.set({ fontSize }) + this.canvas + ?.getObjects() + .filter((obj) => obj.name === 'lengthText' && obj.parent === this) + .forEach((text) => { + text.set({ fontSize: fontSize }) + }) }, _render: function (ctx) { this.callSuper('_render', ctx) @@ -700,6 +705,14 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, { text.set({ visible: isView }) }) }, + setScaleX(scale) { + this.scaleX = scale + this.addLengthText() + }, + setScaleY(scale) { + this.scaleY = scale + this.addLengthText() + }, divideLine() { splitPolygonWithLines(this) },