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

connectDragSource can specify custom dataTransfer data #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/HTML5Backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ export default class HTML5Backend {
const sourceNodeOptions = this.sourceNodeOptions[sourceId];

return defaults(sourceNodeOptions || {}, {
dropEffect: 'move'
dropEffect: 'move',
dataTransferData: {}
});
}

Expand All @@ -147,6 +148,10 @@ export default class HTML5Backend {
return this.getCurrentSourceNodeOptions().dropEffect;
}

getCurrentDataTransferData() {
return this.getCurrentSourceNodeOptions().dataTransferData;
}

getCurrentSourcePreviewNodeOptions() {
const sourceId = this.monitor.getSourceId();
const sourcePreviewNodeOptions = this.sourcePreviewNodeOptions[sourceId];
Expand Down Expand Up @@ -297,8 +302,9 @@ export default class HTML5Backend {
}

try {
// Firefox won't drag without setting data
dataTransfer.setData('application/json', {});
// a) Firefox won't drag without setting data
// b) Interop with external drag targets/drag libs
dataTransfer.setData('application/json', this.getCurrentDataTransferData());
} catch (err) {
// IE doesn't support MIME types in setData
}
Expand Down