File tree 2 files changed +13
-7
lines changed
2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -319,13 +319,15 @@ export class GridStackEngine {
319
319
return node ;
320
320
}
321
321
322
- public removeNode ( node : GridStackNode , removeDOM = true , triggerRemoveEvent = false ) : GridStackEngine {
323
- if ( triggerRemoveEvent ) { // we wait until final drop to manually track removed items (rather than during drag)
322
+ public removeNode ( node : GridStackNode , removeDOM = true , triggerEvent = false ) : GridStackEngine {
323
+ if ( triggerEvent ) { // we wait until final drop to manually track removed items (rather than during drag)
324
324
this . removedNodes . push ( node ) ;
325
325
}
326
326
node . _id = null ; // hint that node is being removed
327
- this . nodes = this . nodes . filter ( n => n !== node ) ;
328
- this . _packNodes ( ) ;
327
+ this . nodes . splice ( this . nodes . findIndex ( n => n === node ) , 1 ) ;
328
+ if ( ! this . float ) {
329
+ this . _packNodes ( ) ;
330
+ }
329
331
this . _notify ( node , removeDOM ) ;
330
332
return this ;
331
333
}
Original file line number Diff line number Diff line change @@ -1214,10 +1214,11 @@ export class GridStack {
1214
1214
}
1215
1215
1216
1216
/** @internal prepares the element for drag&drop **/
1217
- private _prepareElementsByNode ( el : GridItemHTMLElement , node : GridStackNode ) : GridStack {
1217
+ private _prepareDragDropByNode ( node : GridStackNode ) : GridStack {
1218
1218
// variables used/cashed between the 3 start/move/end methods, in addition to node passed above
1219
1219
let cellWidth : number ;
1220
1220
let cellHeight : number ;
1221
+ let el = node . el ;
1221
1222
1222
1223
/** called when item starts moving/resizing */
1223
1224
let onStartMoving = ( event , ui ) => {
@@ -1399,7 +1400,7 @@ export class GridStack {
1399
1400
node = this . engine . addNode ( node , triggerAddEvent ) ;
1400
1401
el . gridstackNode = node ;
1401
1402
1402
- this . _prepareElementsByNode ( el , node ) ;
1403
+ this . _prepareDragDropByNode ( node ) ;
1403
1404
return this ;
1404
1405
}
1405
1406
@@ -1699,7 +1700,10 @@ export class GridStack {
1699
1700
}
1700
1701
1701
1702
// wait till we return out of the drag callback to set the new drag&resize handler or they may get messed up
1702
- window . setTimeout ( ( ) => this . _prepareElementsByNode ( el , node ) ) ;
1703
+ // IFF we are still there (soe application will use as placeholder and insert their real widget instead)
1704
+ window . setTimeout ( ( ) => {
1705
+ if ( node . el && node . el . parentElement ) this . _prepareDragDropByNode ( node ) ;
1706
+ } ) ;
1703
1707
1704
1708
return false ; // prevent parent from receiving msg (which may be grid as well)
1705
1709
} ) ;
You can’t perform that action at this time.
0 commit comments