(e: DragEvent)
| 255 | }; |
| 256 | |
| 257 | let onDragEnd = (e: DragEvent) => { |
| 258 | // Prevent the drag event from propagating to any parent draggables |
| 259 | e.stopPropagation(); |
| 260 | |
| 261 | if (typeof options.onDragEnd === 'function') { |
| 262 | let event: DragEndEvent = { |
| 263 | type: 'dragend', |
| 264 | x: e.clientX, |
| 265 | y: e.clientY, |
| 266 | dropOperation: DROP_EFFECT_TO_DROP_OPERATION[e.dataTransfer.dropEffect] |
| 267 | }; |
| 268 | |
| 269 | // Chrome Android always returns none as its dropEffect so we use the drop effect set in useDrop via |
| 270 | // onDragEnter/onDragOver instead. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951 |
| 271 | if (globalDropEffect) { |
| 272 | event.dropOperation = DROP_EFFECT_TO_DROP_OPERATION[globalDropEffect]; |
| 273 | } |
| 274 | options.onDragEnd(event); |
| 275 | } |
| 276 | |
| 277 | setDragging(null); |
| 278 | removeAllGlobalListeners(); |
| 279 | setGlobalAllowedDropOperations(DROP_OPERATION.none); |
| 280 | setGlobalDropEffect(undefined); |
| 281 | }; |
| 282 | |
| 283 | // If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801 |
| 284 | // In this case, we need to manually call onDragEnd on cleanup |
no test coverage detected