Skip to content

Commit 66dc109

Browse files
committed
Disable dragstart event on images (only Firefox)
1 parent 76e83a8 commit 66dc109

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/MouseBackend.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export default class MouseBackend {
4646
this.handleWindowMoveEndCapture.bind(this)
4747
this.handleWindowClick =
4848
this.handleWindowClick.bind(this)
49+
this.handleWindowDragstart =
50+
this.handleWindowDragstart.bind(this)
4951
}
5052

5153
setup() {
@@ -68,6 +70,8 @@ export default class MouseBackend {
6870
this.handleWindowMoveEndCapture, true)
6971
window.addEventListener('click',
7072
this.handleWindowClick, true)
73+
window.addEventListener('dragstart',
74+
this.handleWindowDragstart, true)
7175
}
7276

7377
getSourceClientOffset (sourceId) {
@@ -92,6 +96,8 @@ export default class MouseBackend {
9296
'mouseup', this.handleWindowMoveEndCapture, true)
9397
window.removeEventListener(
9498
'click', this.handleWindowClick, true)
99+
window.removeEventListener(
100+
'dragstart', this.handleWindowDragstart, true)
95101
}
96102

97103
connectDragSource(sourceId, node) {
@@ -209,6 +215,11 @@ export default class MouseBackend {
209215
this.preventClick = false
210216
}
211217

218+
// Disable drag on images (Firefox)
219+
handleWindowDragstart(e) {
220+
e.preventDefault()
221+
}
222+
212223
installSourceNodeRemovalObserver (node) {
213224
this.uninstallSourceNodeRemovalObserver()
214225

0 commit comments

Comments
 (0)