@@ -32,7 +32,6 @@ export default class HTML5Backend {
32
32
this . getSourceClientOffset = this . getSourceClientOffset . bind ( this ) ;
33
33
this . handleTopDragStart = this . handleTopDragStart . bind ( this ) ;
34
34
this . handleTopDragStartCapture = this . handleTopDragStartCapture . bind ( this ) ;
35
- this . handleTopDragEndCapture = this . handleTopDragEndCapture . bind ( this ) ;
36
35
this . handleTopDragEnter = this . handleTopDragEnter . bind ( this ) ;
37
36
this . handleTopDragEnterCapture = this . handleTopDragEnterCapture . bind ( this ) ;
38
37
this . handleTopDragLeaveCapture = this . handleTopDragLeaveCapture . bind ( this ) ;
@@ -41,7 +40,7 @@ export default class HTML5Backend {
41
40
this . handleTopDrop = this . handleTopDrop . bind ( this ) ;
42
41
this . handleTopDropCapture = this . handleTopDropCapture . bind ( this ) ;
43
42
this . handleSelectStart = this . handleSelectStart . bind ( this ) ;
44
- this . endDragIfSourceWasRemovedFromDOM = this . endDragIfSourceWasRemovedFromDOM . bind ( this ) ;
43
+ this . endDrag = this . endDrag . bind ( this ) ;
45
44
this . endDragNativeItem = this . endDragNativeItem . bind ( this ) ;
46
45
this . asyncEndDragNativeItem = this . asyncEndDragNativeItem . bind ( this ) ;
47
46
}
@@ -83,7 +82,6 @@ export default class HTML5Backend {
83
82
addEventListeners ( target ) {
84
83
target . addEventListener ( 'dragstart' , this . handleTopDragStart ) ;
85
84
target . addEventListener ( 'dragstart' , this . handleTopDragStartCapture , true ) ;
86
- target . addEventListener ( 'dragend' , this . handleTopDragEndCapture , true ) ;
87
85
target . addEventListener ( 'dragenter' , this . handleTopDragEnter ) ;
88
86
target . addEventListener ( 'dragenter' , this . handleTopDragEnterCapture , true ) ;
89
87
target . addEventListener ( 'dragleave' , this . handleTopDragLeaveCapture , true ) ;
@@ -96,7 +94,6 @@ export default class HTML5Backend {
96
94
removeEventListeners ( target ) {
97
95
target . removeEventListener ( 'dragstart' , this . handleTopDragStart ) ;
98
96
target . removeEventListener ( 'dragstart' , this . handleTopDragStartCapture , true ) ;
99
- target . removeEventListener ( 'dragend' , this . handleTopDragEndCapture , true ) ;
100
97
target . removeEventListener ( 'dragenter' , this . handleTopDragEnter ) ;
101
98
target . removeEventListener ( 'dragenter' , this . handleTopDragEnterCapture , true ) ;
102
99
target . removeEventListener ( 'dragleave' , this . handleTopDragLeaveCapture , true ) ;
@@ -228,12 +225,7 @@ export default class HTML5Backend {
228
225
this . currentNativeSource = null ;
229
226
}
230
227
231
- endDragIfSourceWasRemovedFromDOM ( ) {
232
- const node = this . currentDragSourceNode ;
233
- if ( document . body . contains ( node ) ) {
234
- return ;
235
- }
236
-
228
+ endDrag ( ) {
237
229
if ( this . clearCurrentDragSourceNode ( ) ) {
238
230
this . actions . endDrag ( ) ;
239
231
}
@@ -247,16 +239,17 @@ export default class HTML5Backend {
247
239
248
240
// Receiving a mouse event in the middle of a dragging operation
249
241
// means it has ended and the drag source node disappeared from DOM,
250
- // so the browser didn't dispatch the dragend event.
251
- this . window . addEventListener ( 'mousemove' , this . endDragIfSourceWasRemovedFromDOM , true ) ;
242
+ // so the browser didn't dispatch the dragend event or browser fail
243
+ // to trigger dragend (i.e: Chrome 59)
244
+ this . window . addEventListener ( 'mousemove' , this . endDrag , true ) ;
252
245
}
253
246
254
247
clearCurrentDragSourceNode ( ) {
255
248
if ( this . currentDragSourceNode ) {
256
249
this . currentDragSourceNode = null ;
257
250
this . currentDragSourceNodeOffset = null ;
258
251
this . currentDragSourceNodeOffsetChanged = false ;
259
- this . window . removeEventListener ( 'mousemove' , this . endDragIfSourceWasRemovedFromDOM , true ) ;
252
+ this . window . removeEventListener ( 'mousemove' , this . endDrag , true ) ;
260
253
return true ;
261
254
}
262
255
@@ -389,15 +382,6 @@ export default class HTML5Backend {
389
382
}
390
383
}
391
384
392
- handleTopDragEndCapture ( ) {
393
- if ( this . clearCurrentDragSourceNode ( ) ) {
394
- // Firefox can dispatch this event in an infinite loop
395
- // if dragend handler does something like showing an alert.
396
- // Only proceed if we have not handled it already.
397
- this . actions . endDrag ( ) ;
398
- }
399
- }
400
-
401
385
handleTopDragEnterCapture ( e ) {
402
386
this . dragEnterTargetIds = [ ] ;
403
387
@@ -539,8 +523,6 @@ export default class HTML5Backend {
539
523
540
524
if ( this . isDraggingNativeItem ( ) ) {
541
525
this . endDragNativeItem ( ) ;
542
- } else {
543
- this . endDragIfSourceWasRemovedFromDOM ( ) ;
544
526
}
545
527
}
546
528
0 commit comments