Skip to content
This repository was archived by the owner on Jun 18, 2018. It is now read-only.

Commit 2b7b2e3

Browse files
committed
End dragging native item if we detect mousemove event
Fixes #4
1 parent 295805c commit 2b7b2e3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/HTML5Backend.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default class HTML5Backend {
3131
this.handleTopDropCapture = this.handleTopDropCapture.bind(this);
3232
this.handleSelectStart = this.handleSelectStart.bind(this);
3333
this.endDragIfSourceWasRemovedFromDOM = this.endDragIfSourceWasRemovedFromDOM.bind(this);
34+
this.endDragNativeItem = this.endDragNativeItem.bind(this);
3435
}
3536

3637
setup() {
@@ -170,9 +171,18 @@ export default class HTML5Backend {
170171
this.currentNativeSource = new SourceType();
171172
this.currentNativeHandle = this.registry.addSource(type, this.currentNativeSource);
172173
this.actions.beginDrag([this.currentNativeHandle]);
174+
175+
// If mousemove fires, the drag is over but browser failed to tell us.
176+
window.addEventListener('mousemove', this.endDragNativeItem, true);
173177
}
174178

175179
endDragNativeItem() {
180+
if (!this.isDraggingNativeItem()) {
181+
return;
182+
}
183+
184+
window.removeEventListener('mousemove', this.endDragNativeItem, true);
185+
176186
this.actions.endDrag();
177187
this.registry.removeSource(this.currentNativeHandle);
178188
this.currentNativeHandle = null;

0 commit comments

Comments
 (0)