Browse Source

Fix getting multiple files from drag event

master
Eduard Kuzmenko 4 years ago
parent
commit
b630c74b21
  1. 7
      src/helpers/dom.ts

7
src/helpers/dom.ts

@ -640,13 +640,16 @@ export async function getFilesFromEvent(e: ClipboardEvent | DragEvent, onlyTypes @@ -640,13 +640,16 @@ export async function getFilesFromEvent(e: ClipboardEvent | DragEvent, onlyTypes
// @ts-ignore
const items = (e.dataTransfer || e.clipboardData || e.originalEvent.clipboardData).items;
const promises: Promise<any>[] = [];
for(let i = 0; i < items.length; ++i) {
const item: DataTransferItem = items[i];
if(item.kind === 'file') {
const entry = onlyTypes ? item : item.webkitGetAsEntry() || item.getAsFile();
await scanFiles(entry);
const entry = (onlyTypes ? item : item.webkitGetAsEntry()) || item.getAsFile();
promises.push(scanFiles(entry));
}
}
await Promise.all(promises);
}
/* if(!onlyTypes) {

Loading…
Cancel
Save