@@ -794,8 +794,8 @@ export class GridStack {
794
794
delete this . _ignoreLayoutsNodeChange ;
795
795
delete this . _insertNotAppend ;
796
796
prevCB ? GridStack . addRemoveCB = prevCB : delete GridStack . addRemoveCB ;
797
- // delay adding animation back
798
- if ( noAnim && this . opts . animate ) setTimeout ( ( ) => this . setAnimation ( this . opts . animate ) ) ;
797
+ // delay adding animation back, but check to make sure grid (opt) is still around
798
+ if ( noAnim && this . opts ? .animate ) setTimeout ( ( ) => { if ( this . opts ) this . setAnimation ( this . opts . animate ) } ) ;
799
799
return this ;
800
800
}
801
801
@@ -1245,7 +1245,7 @@ export class GridStack {
1245
1245
GridStack . addRemoveCB ( this . el , n , false , false ) ;
1246
1246
}
1247
1247
delete n . el . gridstackNode ;
1248
- this . _removeDD ( n . el ) ;
1248
+ if ( ! this . opts . staticGrid ) this . _removeDD ( n . el ) ;
1249
1249
} ) ;
1250
1250
this . engine . removeAll ( removeDOM , triggerEvent ) ;
1251
1251
if ( triggerEvent ) this . _triggerRemoveEvent ( ) ;
@@ -2190,7 +2190,7 @@ export class GridStack {
2190
2190
}
2191
2191
2192
2192
// clear any marked for complete removal (Note: don't check _isAboutToRemove as that is cleared above - just do it)
2193
- this . _itemRemoving ( node . el , false ) ;
2193
+ GridStack . _itemRemoving ( node . el , false ) ;
2194
2194
2195
2195
dd . on ( el , 'drag' , onDrag ) ;
2196
2196
// make sure this is called at least once when going fast #1578
@@ -2289,35 +2289,35 @@ export class GridStack {
2289
2289
this . _gsEventHandler [ 'dropped' ] ( { ...event , type : 'dropped' } , origNode && origNode . grid ? origNode : undefined , node ) ;
2290
2290
}
2291
2291
2292
- // delay adding animation back
2293
- if ( noAnim ) setTimeout ( ( ) => this . setAnimation ( this . opts . animate ) ) ;
2292
+ // delay adding animation back, but check to make sure grid (opt) is still around
2293
+ if ( noAnim ) setTimeout ( ( ) => { if ( this . opts ) this . setAnimation ( this . opts . animate ) } ) ;
2294
2294
2295
2295
return false ; // prevent parent from receiving msg (which may be grid as well)
2296
2296
} ) ;
2297
2297
return this ;
2298
2298
}
2299
2299
2300
2300
/** @internal mark item for removal */
2301
- private _itemRemoving ( el : GridItemHTMLElement , remove : boolean ) {
2302
- let node = el ? el . gridstackNode : undefined ;
2303
- if ( ! node || ! node . grid || el . classList . contains ( this . opts . removableOptions . decline ) ) return ;
2301
+ private static _itemRemoving ( el : GridItemHTMLElement , remove : boolean ) {
2302
+ const node = el ? el . gridstackNode : undefined ;
2303
+ if ( ! node ? .grid || el . classList . contains ( node . grid . opts . removableOptions . decline ) ) return ;
2304
2304
remove ? node . _isAboutToRemove = true : delete node . _isAboutToRemove ;
2305
2305
remove ? el . classList . add ( 'grid-stack-item-removing' ) : el . classList . remove ( 'grid-stack-item-removing' ) ;
2306
2306
}
2307
2307
2308
2308
/** @internal called to setup a trash drop zone if the user specifies it */
2309
2309
protected _setupRemoveDrop ( ) : GridStack {
2310
- if ( ! this . opts . staticGrid && typeof this . opts . removable === 'string' ) {
2311
- let trashEl = document . querySelector ( this . opts . removable ) as HTMLElement ;
2312
- if ( ! trashEl ) return this ;
2313
- // only register ONE drop-over/dropout callback for the 'trash', and it will
2314
- // update the passed in item and parent grid because the 'trash' is a shared resource anyway,
2315
- // and Native DD only has 1 event CB (having a list and technically a per grid removableOptions complicates things greatly)
2316
- if ( ! dd . isDroppable ( trashEl ) ) {
2317
- dd . droppable ( trashEl , this . opts . removableOptions )
2318
- . on ( trashEl , 'dropover' , ( event , el ) => this . _itemRemoving ( el , true ) )
2319
- . on ( trashEl , 'dropout ' , ( event , el ) => this . _itemRemoving ( el , false ) ) ;
2320
- }
2310
+ if ( typeof this . opts . removable !== 'string' ) return this ;
2311
+ let trashEl = document . querySelector ( this . opts . removable ) as HTMLElement ;
2312
+ if ( ! trashEl ) return this ;
2313
+
2314
+ // only register ONE static drop-over/dropout callback for the 'trash', and it will
2315
+ // update the passed in item and parent grid because the '.trash' is a shared resource anyway,
2316
+ // and Native DD only has 1 event CB (having a list and technically a per grid removableOptions complicates things greatly)
2317
+ if ( ! this . opts . staticGrid && ! dd . isDroppable ( trashEl ) ) {
2318
+ dd . droppable ( trashEl , this . opts . removableOptions )
2319
+ . on ( trashEl , 'dropover ' , ( event , el ) => GridStack . _itemRemoving ( el , true ) )
2320
+ . on ( trashEl , 'dropout' , ( event , el ) => GridStack . _itemRemoving ( el , false ) ) ;
2321
2321
}
2322
2322
return this ;
2323
2323
}
@@ -2592,7 +2592,7 @@ export class GridStack {
2592
2592
2593
2593
if ( this . opts . removable === true ) { // boolean vs a class string
2594
2594
// item leaving us and we are supposed to remove on leave (no need to drag onto trash) mark it so
2595
- this . _itemRemoving ( el , true ) ;
2595
+ GridStack . _itemRemoving ( el , true ) ;
2596
2596
}
2597
2597
2598
2598
// finally if item originally came from another grid, but left us, restore things back to prev info
0 commit comments