send/app/dragManager.js

28 lines
808 B
JavaScript
Raw Normal View History

2018-07-31 18:09:18 +00:00
import { checkSize } from './utils';
export default function(state, emitter) {
emitter.on('DOMContentLoaded', () => {
document.body.addEventListener('dragover', event => {
if (state.route === '/') {
event.preventDefault();
2018-07-31 18:09:18 +00:00
const files = document.querySelector('.uploadedFilesWrapper');
files.classList.add('uploadArea--noEvents');
}
});
document.body.addEventListener('drop', event => {
if (state.route === '/' && !state.uploading) {
event.preventDefault();
2018-02-19 22:29:13 +00:00
document
.querySelector('.uploadArea')
.classList.remove('uploadArea--dragging');
2018-07-31 18:09:18 +00:00
const target = event.dataTransfer;
2018-07-26 05:26:11 +00:00
2018-07-31 18:09:18 +00:00
checkSize(target.files, state.files);
emitter.emit('addFiles', { files: target.files });
}
});
});
}