drop.chapril.org-firefoxsend/app/dragManager.js

24 lines
726 B
JavaScript
Raw Normal View History

export default function(state, emitter) {
emitter.on('DOMContentLoaded', () => {
document.body.addEventListener('dragover', event => {
if (state.route === '/') {
event.preventDefault();
2018-07-31 20:09:18 +02: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 23:29:13 +01:00
document
.querySelector('.uploadArea')
.classList.remove('uploadArea--dragging');
2018-07-31 20:09:18 +02:00
2018-08-03 21:24:41 +02:00
const files = Array.from(event.dataTransfer.files);
2018-07-31 20:09:18 +02:00
2018-08-03 21:24:41 +02:00
emitter.emit('addFiles', { files });
}
});
});
}