diff --git a/packages/core/src/style_manager/model/Property.ts b/packages/core/src/style_manager/model/Property.ts index 4eed38023..a248b01b6 100644 --- a/packages/core/src/style_manager/model/Property.ts +++ b/packages/core/src/style_manager/model/Property.ts @@ -354,7 +354,7 @@ export default class Property = PropertyProps> ext } __getClearProps() { - return { value: '' } as unknown as Partial; + return { value: '', important: false } as unknown as Partial; } /** @@ -492,7 +492,7 @@ export default class Property = PropertyProps> ext const fn = this.get('functionName'); const def = this.getDefaultValue(); let value = isUndefined(val) ? (this.get('value') as string) : val; - const hasValue = !isUndefined(value) && value !== ''; + const hasValue = this.hasValue(); if (value && def && value === def) { return def; diff --git a/packages/core/src/utils/Resizer.ts b/packages/core/src/utils/Resizer.ts index 3b52f7cc2..e239fab4e 100644 --- a/packages/core/src/utils/Resizer.ts +++ b/packages/core/src/utils/Resizer.ts @@ -676,11 +676,13 @@ export default class Resizer { const parentH = this.parentDim!.h; const unitWidth = this.opts.unitWidth; const unitHeight = this.opts.unitHeight; + const parentRect = this.getParentRect(); const startW = unitWidth === '%' ? (startDim.w / 100) * parentW : startDim.w; const startH = unitHeight === '%' ? (startDim.h / 100) * parentH : startDim.h; + const box: RectDim = { - t: startDim.t, - l: startDim.l, + t: startDim.t - parentRect.top, + l: startDim.l - parentRect.left, w: startW, h: startH, }; @@ -750,4 +752,20 @@ export default class Resizer { return box; } + + getParentRect(): BoundingRect { + let parentRect = { left: 0, top: 0, width: 0, height: 0 }; + const { el } = this; + + if (!el) return parentRect; + + const { offsetParent } = el; + + // Check if the parent or any ancestor has `position: relative`, `absolute`, `fixed`, or `sticky` + if (offsetParent && offsetParent.tagName !== 'BODY') { + parentRect = this.getElementPos(offsetParent as HTMLElement); + } + + return parentRect; + } }