aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/EquationBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/EquationBox.tsx')
-rw-r--r--src/client/views/nodes/EquationBox.tsx14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/client/views/nodes/EquationBox.tsx b/src/client/views/nodes/EquationBox.tsx
index d8b8bcb27..d347c285b 100644
--- a/src/client/views/nodes/EquationBox.tsx
+++ b/src/client/views/nodes/EquationBox.tsx
@@ -84,8 +84,18 @@ export class EquationBox extends ViewBoxBaseComponent<FieldViewProps>() {
updateSize = () => {
const style = this._ref.current && getComputedStyle(this._ref.current.element.current);
if (style?.width.endsWith('px') && style?.height.endsWith('px')) {
- this.layoutDoc._width = Math.max(35, Number(style.width.replace('px', '')));
- this.layoutDoc._height = Math.max(25, Number(style.height.replace('px', '')));
+ if (this.layoutDoc._nativeWidth) {
+ // if equation has been scaled then editing the expression must also edit the native dimensions to keep the aspect ratio
+ const prevNwidth = NumCast(this.layoutDoc._nativeWidth);
+ const prevNheight = NumCast(this.layoutDoc._nativeHeight);
+ this.layoutDoc._nativeWidth = Math.max(35, Number(style.width.replace('px', '')));
+ this.layoutDoc._nativeHeight = Math.max(25, Number(style.height.replace('px', '')));
+ this.layoutDoc._width = (NumCast(this.layoutDoc._width) * NumCast(this.layoutDoc._nativeWidth)) / prevNwidth;
+ this.layoutDoc._height = (NumCast(this.layoutDoc._height) * NumCast(this.layoutDoc._nativeHeight)) / prevNheight;
+ } else {
+ this.layoutDoc._width = Math.max(35, Number(style.width.replace('px', '')));
+ this.layoutDoc._height = Math.max(25, Number(style.height.replace('px', '')));
+ }
}
};
render() {