Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolved bug with top/left being sticky when resizing from l/t side #5017

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/commands/view/SelectComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ export default {
style[keyHeight] = autoHeight ? 'auto' : `${rect.h}${unitHeight}`;
}

style.top = rect.t + unitHeight;
style.left = rect.l + unitWidth;

modelToStyle.addStyle({ ...style, en }, { avoidStore: !store });
const updateEvent = 'update:component:style';
const eventToListen = `${updateEvent}:${keyHeight} ${updateEvent}:${keyWidth}`;
Expand Down
12 changes: 7 additions & 5 deletions src/utils/Resizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ export default class Resizer {
const elStyle = el.style as Record<string, any>;
elStyle[keyWidth!] = rect.w + unitWidth!;
elStyle[keyHeight!] = rect.h + unitHeight!;
elStyle.top = rect.t + unitHeight!;
elStyle.left = rect.l + unitWidth!;
}

this.updateContainer();
Expand Down Expand Up @@ -663,9 +665,9 @@ export default class Resizer {
const unitHeight = this.opts.unitHeight;
const startW = unitWidth === '%' ? (startDim.w / 100) * parentW : startDim.w;
const startH = unitHeight === '%' ? (startDim.h / 100) * parentH : startDim.h;
var box = {
t: 0,
l: 0,
var box: RectDim = {
t: startDim.t,
l: startDim.l,
w: startW,
h: startH,
};
Expand Down Expand Up @@ -722,10 +724,10 @@ export default class Resizer {
}

if (~attr.indexOf('l')) {
box.l = startDim.w - box.w;
box.l += startDim.w - box.w;
}
if (~attr.indexOf('t')) {
box.t = startDim.h - box.h;
box.t += startDim.h - box.h;
}

return box;
Expand Down