send/app/dragManager.js

23 lines
576 B
JavaScript
Raw Permalink Normal View History

export default function(state, emitter) {
emitter.on('DOMContentLoaded', () => {
document.body.addEventListener('dragover', event => {
if (state.route === '/') {
event.preventDefault();
}
});
document.body.addEventListener('drop', event => {
2018-11-19 18:48:52 +00:00
if (
state.route === '/' &&
!state.uploading &&
event.dataTransfer &&
event.dataTransfer.files
) {
event.preventDefault();
2018-10-31 18:40:54 +00:00
emitter.emit('addFiles', {
files: Array.from(event.dataTransfer.files)
});
}
});
});
}