File tree Expand file tree Collapse file tree 4 files changed +11
-7
lines changed
Expand file tree Collapse file tree 4 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ Change log
7373
7474## 6.0.1-dev (TBD)
7575* fixed [ #2034 ] ( https://github.com/gridstack/gridstack.js/issues/2034 ) ` removeWidget() ` breaking resize handle feedback
76+ * fixed [ #2043 ] ( https://github.com/gridstack/gridstack.js/issues/2043 ) when swapping shapes in maxRow grid, make sure we still check for 50% coverage
7677
7778## 6.0.1 (2022-08-27)
7879* fixed ` float(val) ` to set on grid and engine, so save() will read it.
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
120120 this . el . removeEventListener ( 'mouseout' , this . _mouseOut ) ;
121121 if ( DDManager . overResizeElement === this ) {
122122 delete DDManager . overResizeElement ;
123- }
123+ }
124124 }
125125 return this ;
126126 }
Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ export class GridStackEngine {
175175 collide = n ;
176176 }
177177 } ) ;
178+ o . collide = collide ; // save it so we don't have to find it again
178179 return collide ;
179180 }
180181
@@ -541,12 +542,12 @@ export class GridStackEngine {
541542 } ) ;
542543 if ( ! clonedNode ) return false ;
543544
544- // make sure we are still valid size
545- let canMove = clone . moveNode ( clonedNode , o ) && clone . getRow ( ) <= this . maxRow ;
546- // turns out we can't grow, then see if we can swap instead (ex: full grid) if we're not resizing
547- if ( ! canMove && ! o . resizing ) {
548- let collide = this . collide ( node , o ) ;
549- if ( collide && this . swap ( node , collide ) ) {
545+ // check if we're covering 50% collision and could move
546+ let canMove = clone . moveNode ( clonedNode , o ) ;
547+ // make sure we are still valid grid max, else check if we can force a swap (float=true, or different shapes) on non-resize
548+ if ( ! o . resizing && canMove && o . collide && this . float && clone . getRow ( ) > this . maxRow ) {
549+ let collide = o . collide . el . gridstackNode ; // find the source node the clone collided with
550+ if ( this . swap ( node , collide ) ) { // swaps and mark dirty
550551 this . _notify ( ) ;
551552 return true ;
552553 }
Original file line number Diff line number Diff line change @@ -253,6 +253,8 @@ export interface GridStackMoveOpts extends GridStackPosition {
253253 rect ?: GridStackPosition ;
254254 /** true if we're live resizing */
255255 resizing ?: boolean ;
256+ /** best node (most coverage) we collied with */
257+ collide ?: GridStackNode ;
256258}
257259
258260export interface GridStackPosition {
You can’t perform that action at this time.
0 commit comments