File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
184184 this . temporalRect = this . _getChange ( event , dir ) ;
185185 this . _applyChange ( ) ;
186186 const ev = Utils . initEvent < MouseEvent > ( event , { type : 'resize' , target : this . el } ) ;
187+ ( ev as any ) . resizeDir = dir ; // expose handle direction so _dragOrResize can avoid position drift
187188 if ( this . option . resize ) {
188189 this . option . resize ( ev , this . _ui ( ) ) ;
189190 }
Original file line number Diff line number Diff line change @@ -2928,11 +2928,16 @@ export class GridStack {
29282928 if ( node . w === p . w && node . h === p . h ) return ;
29292929 if ( node . _lastTried && node . _lastTried . w === p . w && node . _lastTried . h === p . h ) return ; // skip one we tried (but failed)
29302930
2931- // if we size on left/top side this might move us, so get possible new position as well
2932- const left = ui . position . left + mLeft ;
2933- const top = ui . position . top + mTop ;
2934- p . x = Math . round ( left / cellWidth ) ;
2935- p . y = Math . round ( top / cellHeight ) ;
2931+ // only recalculate position for handles that move the top-left corner (N/W).
2932+ // for SE/S/E handles the top-left is anchored — recalculating from pixels causes
2933+ // rounding drift on fine grids where cellWidth/cellHeight are only a few pixels. #385 #1356
2934+ const dir = ( ( event as any ) . resizeDir || '' ) as string ;
2935+ if ( dir . includes ( 'w' ) || dir . includes ( 'n' ) ) {
2936+ const left = ui . position . left + mLeft ;
2937+ const top = ui . position . top + mTop ;
2938+ if ( dir . includes ( 'w' ) ) p . x = Math . round ( left / cellWidth ) ;
2939+ if ( dir . includes ( 'n' ) ) p . y = Math . round ( top / cellHeight ) ;
2940+ }
29362941
29372942 resizing = true ;
29382943 }
You can’t perform that action at this time.
0 commit comments