Skip to content

Commit

Permalink
Take into account borders during a component move. Fixes #5621 Closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Feb 10, 2024
1 parent 58a6ff7 commit ec4f2d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/canvas/view/CanvasView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export interface MarginPaddingOffsets {
paddingRight?: number;
paddingBottom?: number;
paddingLeft?: number;
borderTopWidth?: number;
borderRightWidth?: number;
borderBottomWidth?: number;
borderLeftWidth?: number;
}

export type ElementPosOpts = {
Expand Down Expand Up @@ -516,6 +520,10 @@ export default class CanvasView extends ModuleView<Canvas> {
'paddingRight',
'paddingBottom',
'paddingLeft',
'borderTopWidth',
'borderRightWidth',
'borderBottomWidth',
'borderLeftWidth',
];
marginPaddingOffsets.forEach(offset => {
result[offset] = parseFloat(styles[offset]) * zoom;
Expand Down
10 changes: 7 additions & 3 deletions src/utils/Sorter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1097,9 +1097,13 @@ export default class Sorter extends View {
const offset = trgDim.offsets || {};
const pT = offset.paddingTop || margI;
const pL = offset.paddingLeft || margI;
t = trgDim.top + pT;
l = trgDim.left + pL;
w = parseInt(`${trgDim.width}`) - pL * 2 + un;
const bT = offset.borderTopWidth || 0;
const bL = offset.borderLeftWidth || 0;
const bR = offset.borderRightWidth || 0;
const bWidth = bL + bR;
t = trgDim.top + pT + bT;
l = trgDim.left + pL + bL;
w = parseInt(`${trgDim.width}`) - pL * 2 - bWidth + un;
h = 'auto';
}
}
Expand Down

0 comments on commit ec4f2d6

Please sign in to comment.