send/app/dragManager.js
2018-11-01 10:44:47 -07:00

17 lines
486 B
JavaScript

export default function(state, emitter) {
emitter.on('DOMContentLoaded', () => {
document.body.addEventListener('dragover', event => {
if (state.route === '/') {
event.preventDefault();
}
});
document.body.addEventListener('drop', event => {
if (state.route === '/' && !state.uploading) {
event.preventDefault();
emitter.emit('addFiles', {
files: Array.from(event.dataTransfer.files)
});
}
});
});
}