@@ -91,16 +91,19 @@ export class GridStackEngine {
9191 // (not handled with swap) that could take our place, move ourself past it instead
9292 // but remember that skip down so we only do this one (and push others otherwise).
9393 if ( collide . locked || ( node . _moving && ! node . _skipDown && nn . y > node . y &&
94- ! this . float && ! this . collide ( collide , { ...collide , y : node . y } , node ) ) &&
95- Utils . isIntercepted ( collide , { x : node . x - 0.5 , y : node . y - 0.5 , w : node . w + 1 , h : node . h + 1 } ) ) {
94+ ! this . float && ! this . collide ( collide , { ...collide , y : node . y } , node ) ) && Utils . isTouching ( node , collide ) ) {
9695
9796 node . _skipDown = ( node . _skipDown || nn . y > node . y ) ;
9897 moved = this . moveNode ( node , { ...nn , y : collide . y + collide . h , ...newOpt } ) ;
9998 if ( collide . locked && moved ) {
10099 Utils . copyPos ( nn , node ) ; // moving after lock become our new desired location
101100 } else if ( moved && opt . pack && ! collide . locked ) {
102- // we moved after and will pack: do it now and keep the original drop location to see what else we might push way
101+ // we moved after and will pack: do it now and keep the original drop location, but past the old collide to see what else we might push way
103102 this . _packNodes ( ) ;
103+ if ( moved ) {
104+ nn . y = collide . y + collide . h ;
105+ Utils . copyPos ( node , nn ) ;
106+ }
104107 }
105108 didMove = didMove || moved ;
106109 } else {
@@ -197,19 +200,15 @@ export class GridStackEngine {
197200 a . _dirty = b . _dirty = true ;
198201 return true ;
199202 }
200- // make sure they at least touch (including corners which will skip below as unwanted)
201- function _touching ( ) : boolean {
202- return Utils . isIntercepted ( a , { x : b . x - 0.5 , y :b . y - 0.5 , w : b . w + 1 , h : b . h + 1 } )
203- }
204203 let touching : boolean ; // remember if we called it (vs undefined)
205204
206205 // same size and same row or column, and touching
207- if ( a . w === b . w && a . h === b . h && ( a . x === b . x || a . y === b . y ) && ( touching = _touching ( ) ) )
206+ if ( a . w === b . w && a . h === b . h && ( a . x === b . x || a . y === b . y ) && ( touching = Utils . isTouching ( a , b ) ) )
208207 return _doSwap ( ) ;
209208 if ( touching === false ) return ; // ran test and fail, bail out
210209
211210 // check for taking same columns (but different height) and touching
212- if ( a . w === b . w && a . x === b . x && ( touching || _touching ( ) ) ) {
211+ if ( a . w === b . w && a . x === b . x && ( touching || Utils . isTouching ( a , b ) ) ) {
213212 if ( b . y < a . y ) { let t = a ; a = b ; b = t ; } // swap a <-> b vars so a is first
214213 return _doSwap ( ) ;
215214 }
0 commit comments