filednd

Files Drag and Drop

Features

Demo

filednd

Install

NPM

 npm i filednd
#  or
yarn add filednd 

CDN

<script src="https://unpkg.com/filednd/dist/filednd.js"></script>

API

FileDND

constructor(ele)

import {
    FileDND
} from 'filednd';
const fdnd = new FileDND(document.querySelector('#zone'));

// if you use cdn 
// const fdnd = new filednd.FileDND(document.querySelector('#zone'));

methods

fdnd.dnd((files) => {
    console.log(files);
});
  const treeData = fdnd.toTree();
  const text = fdnd.toFolderTree();
├─ src 
| ├─ assets 
| | ├─ vue.svg 
| ├─ components 
| | ├─ HelloWorld.vue 
| ├─ App.vue 
| ├─ common.js 
| ├─ draw.vue 
| ├─ fly.vue 
| ├─ main.js 
| ├─ style.css 

 fdnd.clear();
 fdnd.dispose();

events

const readStart = () => {

}
fdnd.on('readstart', readStart)
//  fdnd.off('readstart', readStart)
const readEnd = () => {

}
fdnd.on('readend', readEnd)
//  fdnd.off('readstart', readEnd)

file-type If you want to determine the file type, you can refer to this library