@@ -794,8 +794,8 @@ export class GridStack {
794794 delete this . _ignoreLayoutsNodeChange ;
795795 delete this . _insertNotAppend ;
796796 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 ) } ) ;
799799 return this ;
800800 }
801801
@@ -1245,7 +1245,7 @@ export class GridStack {
12451245 GridStack . addRemoveCB ( this . el , n , false , false ) ;
12461246 }
12471247 delete n . el . gridstackNode ;
1248- this . _removeDD ( n . el ) ;
1248+ if ( ! this . opts . staticGrid ) this . _removeDD ( n . el ) ;
12491249 } ) ;
12501250 this . engine . removeAll ( removeDOM , triggerEvent ) ;
12511251 if ( triggerEvent ) this . _triggerRemoveEvent ( ) ;
@@ -2190,7 +2190,7 @@ export class GridStack {
21902190 }
21912191
21922192 // 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 ) ;
21942194
21952195 dd . on ( el , 'drag' , onDrag ) ;
21962196 // make sure this is called at least once when going fast #1578
@@ -2289,35 +2289,35 @@ export class GridStack {
22892289 this . _gsEventHandler [ 'dropped' ] ( { ...event , type : 'dropped' } , origNode && origNode . grid ? origNode : undefined , node ) ;
22902290 }
22912291
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 ) } ) ;
22942294
22952295 return false ; // prevent parent from receiving msg (which may be grid as well)
22962296 } ) ;
22972297 return this ;
22982298 }
22992299
23002300 /** @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 ;
23042304 remove ? node . _isAboutToRemove = true : delete node . _isAboutToRemove ;
23052305 remove ? el . classList . add ( 'grid-stack-item-removing' ) : el . classList . remove ( 'grid-stack-item-removing' ) ;
23062306 }
23072307
23082308 /** @internal called to setup a trash drop zone if the user specifies it */
23092309 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 ) ) ;
23212321 }
23222322 return this ;
23232323 }
@@ -2592,7 +2592,7 @@ export class GridStack {
25922592
25932593 if ( this . opts . removable === true ) { // boolean vs a class string
25942594 // 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 ) ;
25962596 }
25972597
25982598 // finally if item originally came from another grid, but left us, restore things back to prev info
0 commit comments