@@ -9,6 +9,7 @@ import { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';
99import { Utils } from './utils' ;
1010import { DDElementHost } from './dd-element' ;
1111import { isTouch , pointerenter , pointerleave } from './dd-touch' ;
12+ import { GridHTMLElement } from './gridstack' ;
1213
1314export interface DDDroppableOpt {
1415 accept ?: string | ( ( el : HTMLElement ) => boolean ) ;
@@ -86,34 +87,34 @@ export class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt
8687 /** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */
8788 protected _mouseEnter ( e : MouseEvent ) : void {
8889 // console.log(`${count++} Enter ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST
89- if ( ! DDManager . dragElement /* || DDManager.dropElement === this*/ ) return ;
90+ if ( ! DDManager . dragElement ) return ;
9091 if ( ! this . _canDrop ( ) ) return ;
9192 e . preventDefault ( ) ;
9293 e . stopPropagation ( ) ;
9394
95+ // make sure when we enter this, that the last one gets a leave FIRST to correctly cleanup as we don't always do
96+ if ( DDManager . dropElement && DDManager . dropElement !== this ) {
97+ DDManager . dropElement . _mouseLeave ( e as DragEvent ) ;
98+ }
99+ DDManager . dropElement = this ;
100+
94101 const ev = Utils . initEvent < DragEvent > ( e , { target : this . el , type : 'dropover' } ) ;
95102 if ( this . option . over ) {
96103 this . option . over ( ev , this . _ui ( DDManager . dragElement ) )
97104 }
98105 this . triggerEvent ( 'dropover' , ev ) ;
99106 this . el . classList . add ( 'ui-droppable-over' ) ;
100-
101- // make sure when we enter this, that the last one gets a leave to correctly cleanup as we don't always do
102- if ( DDManager . dropElement && DDManager . dropElement !== this ) {
103- DDManager . dropElement . _mouseLeave ( e as DragEvent ) ;
104- }
105- DDManager . dropElement = this ;
106107 // console.log('tracking'); // TEST
107108 }
108109
109110 /** @internal called when the item is leaving our area, stop tracking if we had moving item */
110- protected _mouseLeave ( event : DragEvent ) : void {
111+ protected _mouseLeave ( e : MouseEvent ) : void {
111112 // console.log(`${count++} Leave ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST
112113 if ( ! DDManager . dragElement || DDManager . dropElement !== this ) return ;
113- event . preventDefault ( ) ;
114- event . stopPropagation ( ) ;
114+ e . preventDefault ( ) ;
115+ e . stopPropagation ( ) ;
115116
116- const ev = Utils . initEvent < DragEvent > ( event , { target : this . el , type : 'dropout' } ) ;
117+ const ev = Utils . initEvent < DragEvent > ( e , { target : this . el , type : 'dropout' } ) ;
117118 if ( this . option . out ) {
118119 this . option . out ( ev , this . _ui ( DDManager . dragElement ) )
119120 }
@@ -131,7 +132,7 @@ export class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt
131132 parent = parent . parentElement ;
132133 }
133134 if ( parentDrop ) {
134- parentDrop . _mouseEnter ( event ) ;
135+ parentDrop . _mouseEnter ( e ) ;
135136 }
136137 }
137138 }
0 commit comments