electron-drag-drop
Easily manipulate drag and drop in Electron.
Install
npm install --save electron-drag-drop
Run Examples:
npm start example
Usage
main process
require('electron-drag-drop');
renderer process
<body>
<div id="drag" draggable="true">Draggable Item</div>
<div id="drop" droppable="foobar" multi >Droppable Area</div>
<script>
const {drag, droppable, addon} = require('electron-drag-drop');
let dragEL = document.getElementById('drag');
dragEL.addEventListener('dragstart', event => {
drag.start(event.dataTransfer, {
effect: 'copy',
type: 'foobar',
items: 'Hello World!',
});
});
dragEL.addEventListener('dragend', event => {
drag.end();
});
let dropEL = document.getElementById('drop');
addon(dropEL, droppable);
dropEL._initDroppable(dropEL);
dropEL.addEventListener('drop-area-move', event => {
drag.updateDropEffect(event.detail.dataTransfer, 'copy');
});
</script>
</body>
API Reference
License
MIT © 2017 Johnny Wu