Skip to content

Commit

Permalink
🐛 fix: adjust text and svg resizing constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Sep 13, 2021
1 parent d779f15 commit 9fc8970
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/models/Base/BaseLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ abstract class BaseLayer {
this.class = type;
this.style = new Style();

// 默认锁定左边和顶部
this.setResizingConstraint(ResizingConstraint.Left, ResizingConstraint.Top);

this.frame = new Frame(params);
Expand Down
3 changes: 3 additions & 0 deletions src/models/Layer/Svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class Svg extends BaseLayer {
const svgShape = new Svgson(svgString, { width, height });

this.layers = svgShape.layers;

// 默认锁定长宽
this.setFixedWidthAndHeight();
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/models/Layer/Text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BaseLayer from '../Base/BaseLayer';

import { defaultExportOptions } from '../utils';
import TextStyle, { TextStyleParams } from '../Style/TextStyle';
import { BaseLayerParams, SketchFormat, ResizingConstraint } from '../../types';
import { BaseLayerParams, SketchFormat } from '../../types';

interface TextInitParams extends BaseLayerParams {
text: string;
Expand All @@ -20,7 +20,6 @@ class Text extends BaseLayer {
this.text = text;
this.textStyle = new TextStyle(style);
this.multiline = multiline || false;
this.setResizingConstraint(ResizingConstraint.None);

// 1 - width is set to Fixed
// 0 - width is set to Auto - this helps us avoid issues with browser setting too small width causing line to break
Expand Down

0 comments on commit 9fc8970

Please sign in to comment.