@@ -149,6 +149,9 @@ GridStack.prototype._setupAcceptWidget = function(): GridStack {
149149 return canAccept ;
150150 }
151151 } )
152+ /**
153+ * entering our grid area
154+ */
152155 . on ( this . el , 'dropover' , ( event : Event , el : GridItemHTMLElement , helper : GridItemHTMLElement ) => {
153156
154157 // ignore drop enter on ourself, and prevent parent from receiving event
@@ -188,6 +191,9 @@ GridStack.prototype._setupAcceptWidget = function(): GridStack {
188191 GridStackDD . get ( ) . on ( el , 'drag' , onDrag ) ;
189192 return false ; // prevent parent from receiving msg (which may be grid as well)
190193 } )
194+ /**
195+ * Leaving our grid area...
196+ */
191197 . on ( this . el , 'dropout' , ( event , el : GridItemHTMLElement ) => {
192198 let node = el . gridstackNode ;
193199 if ( ! node ) return ;
@@ -211,6 +217,9 @@ GridStack.prototype._setupAcceptWidget = function(): GridStack {
211217 el . gridstackNode = el . _gridstackNodeOrig ;
212218 return false ; // prevent parent from receiving msg (which may be grid as well)
213219 } )
220+ /**
221+ * end - releasing the mouse
222+ */
214223 . on ( this . el , 'drop' , ( event , el : GridItemHTMLElement , helper : GridItemHTMLElement ) => {
215224 let node = el . gridstackNode ;
216225 let wasAdded = ! ! this . placeholder . parentElement ; // skip items not actually added to us because of constrains, but do cleanup #1419
@@ -435,10 +444,10 @@ GridStack.prototype._prepareDragDropByNode = function(node: GridStackNode): Grid
435444 this . _clearRemovingTimeout ( el ) ;
436445 if ( ! node . _temporaryRemoved ) {
437446 Utils . removePositioningStyles ( target ) ;
438- this . _writePosAttr ( target , node . x , node . y , node . w , node . h ) ;
447+ this . _writePosAttr ( target , node ) ;
439448 } else {
440449 Utils . removePositioningStyles ( target ) ;
441- this . _writePosAttr ( target , node . _beforeDrag . x , node . _beforeDrag . y , node . w , node . h ) ;
450+ this . _writePosAttr ( target , { ... node . _beforeDrag , w : node . w , h : node . h } ) ;
442451 node . x = node . _beforeDrag . x ;
443452 node . y = node . _beforeDrag . y ;
444453 delete node . _temporaryRemoved ;
@@ -490,7 +499,7 @@ GridStack.prototype._onStartMoving = function(event: Event, ui: DDUIData, node:
490499 this . engine . cleanNodes ( )
491500 . beginUpdate ( node ) ;
492501
493- this . _writePosAttr ( this . placeholder , node . x , node . y , node . w , node . h )
502+ this . _writePosAttr ( this . placeholder , node )
494503 this . el . append ( this . placeholder ) ;
495504
496505 node . el = this . placeholder ;
@@ -502,7 +511,7 @@ GridStack.prototype._onStartMoving = function(event: Event, ui: DDUIData, node:
502511 if ( event . type === 'dropover' && ! node . _added ) {
503512 node . _added = true ;
504513 this . engine . addNode ( node ) ;
505- this . _writePosAttr ( this . placeholder , node . x , node . y , node . w , node . h ) ;
514+ this . _writePosAttr ( this . placeholder , node ) ;
506515 node . _moving = true ; // lastly mark as moving object
507516 }
508517
@@ -520,7 +529,7 @@ GridStack.prototype._onStartMoving = function(event: Event, ui: DDUIData, node:
520529
521530/** @internal called when item is being dragged/resized */
522531GridStack . prototype . _dragOrResize = function ( event : Event , ui : DDUIData , node : GridStackNode , cellWidth : number , cellHeight : number ) : void {
523- let el = node . el ;
532+ let el = node . el || event . target as GridItemHTMLElement ;
524533 // calculate the place where we're landing by offsetting margin so actual edge crosses mid point
525534 let left = ui . position . left + ( ui . position . left > node . _lastUiPosition . left ? - this . opts . marginRight : this . opts . marginLeft ) ;
526535 let top = ui . position . top + ( ui . position . top > node . _lastUiPosition . top ? - this . opts . marginBottom : this . opts . marginTop ) ;
@@ -561,10 +570,9 @@ GridStack.prototype._dragOrResize = function(event: Event, ui: DDUIData, node: G
561570 if ( node . _removeTimeout ) this . _clearRemovingTimeout ( el ) ;
562571
563572 if ( node . _temporaryRemoved ) {
573+ node . el = this . placeholder ;
564574 this . engine . addNode ( node ) ;
565- this . _writePosAttr ( this . placeholder , x , y , w , h ) ;
566575 this . el . appendChild ( this . placeholder ) ;
567- node . el = this . placeholder ;
568576 delete node . _temporaryRemoved ;
569577 }
570578 }
@@ -597,7 +605,7 @@ GridStack.prototype._dragOrResize = function(event: Event, ui: DDUIData, node: G
597605 this . _updateContainerHeight ( ) ;
598606
599607 let target = event . target as GridItemHTMLElement ;
600- this . _writePosAttr ( target , node . x , node . y , node . w , node . h ) ;
608+ this . _writePosAttr ( target , node ) ;
601609 if ( this . _gsEventHandler [ event . type ] ) {
602610 this . _gsEventHandler [ event . type ] ( event , target ) ;
603611 }
0 commit comments