1
0
mirror of synced 2025-12-08 01:57:56 +08:00

fix(editor): 添加组件默认添加到视窗中间,如果组件初始化height不是数值,则当0处理

This commit is contained in:
roymondchen
2022-05-31 21:05:22 +08:00
parent 86624f5728
commit 311ff22ae4

View File

@@ -142,9 +142,13 @@ export const toRelative = (node: MNode) => {
const setTop2Middle = (node: MNode, parentNode: MNode, stage: StageCore) => {
const style = node.style || {};
const height = style.height || 0;
let height = style.height || 0;
if (!stage || typeof style.top !== 'undefined' || !parentNode.style || !isNumber(height)) return style;
if (!stage || typeof style.top !== 'undefined' || !parentNode.style) return style;
if (!isNumber(height)) {
height = 0;
}
const { height: parentHeight } = parentNode.style;