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
73
73
74
74
## 6.0.1-dev (TBD)
75
75
* 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
76
77
77
78
## 6.0.1 (2022-08-27)
78
79
* 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
120
120
this . el . removeEventListener ( 'mouseout' , this . _mouseOut ) ;
121
121
if ( DDManager . overResizeElement === this ) {
122
122
delete DDManager . overResizeElement ;
123
- }
123
+ }
124
124
}
125
125
return this ;
126
126
}
Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ export class GridStackEngine {
175
175
collide = n ;
176
176
}
177
177
} ) ;
178
+ o . collide = collide ; // save it so we don't have to find it again
178
179
return collide ;
179
180
}
180
181
@@ -541,12 +542,12 @@ export class GridStackEngine {
541
542
} ) ;
542
543
if ( ! clonedNode ) return false ;
543
544
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
550
551
this . _notify ( ) ;
551
552
return true ;
552
553
}
Original file line number Diff line number Diff line change @@ -253,6 +253,8 @@ export interface GridStackMoveOpts extends GridStackPosition {
253
253
rect ?: GridStackPosition ;
254
254
/** true if we're live resizing */
255
255
resizing ?: boolean ;
256
+ /** best node (most coverage) we collied with */
257
+ collide ?: GridStackNode ;
256
258
}
257
259
258
260
export interface GridStackPosition {
You can’t perform that action at this time.
0 commit comments