Skip to content
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
1 change: 1 addition & 0 deletions src/dd-resizable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
this.temporalRect = this._getChange(event, dir);
this._applyChange();
const ev = Utils.initEvent<MouseEvent>(event, { type: 'resize', target: this.el });
(ev as any).resizeDir = dir; // expose handle direction so _dragOrResize can avoid position drift
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a custom type for proper TS support.

if (this.option.resize) {
this.option.resize(ev, this._ui());
}
Expand Down
15 changes: 10 additions & 5 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2928,11 +2928,16 @@ export class GridStack {
if (node.w === p.w && node.h === p.h) return;
if (node._lastTried && node._lastTried.w === p.w && node._lastTried.h === p.h) return; // skip one we tried (but failed)

// if we size on left/top side this might move us, so get possible new position as well
const left = ui.position.left + mLeft;
const top = ui.position.top + mTop;
p.x = Math.round(left / cellWidth);
p.y = Math.round(top / cellHeight);
// only recalculate position for handles that move the top-left corner (N/W).
// for SE/S/E handles the top-left is anchored — recalculating from pixels causes
// rounding drift on fine grids where cellWidth/cellHeight are only a few pixels. #385 #1356
const dir = ((event as any).resizeDir || '') as string;
if (dir.includes('w') || dir.includes('n')) {
const left = ui.position.left + mLeft;
const top = ui.position.top + mTop;
if (dir.includes('w')) p.x = Math.round(left / cellWidth);
if (dir.includes('n')) p.y = Math.round(top / cellHeight);
}

resizing = true;
}
Expand Down