Addon this module to an exists HTMLElmement or assign it to the prototype of a CustomElement.
Addon to an exists HTMLElmement:
<body>
<div id="drop" class="drop-box" droppable="foo,bar" multi >Drop Area</div>
<script>
'use strict'
const {droppable, addon} = require('electron-drag-drop');
let dropEL = document.getElementById('drop');
addon (dropEL, droppable);
dropEL._initDroppable(dropEL);
</script>
</body>
Assign it to the prototype of a CustomElement:
const {droppable, addon} = require('electron-drag-drop');
class MyElement extends window.HTMLElement {
constructor () {
super();
this.attachShadow({
mode: 'open'
});
this.shadowRoot.innerHTML = `
<div class="drop-area">
Drop Area
</div>
`;
this.$droparea = this.shadowRoot.querySelector('.drop-area');
this._inited = false;
}
connectedCallback () {
if ( this._inited ) {
return;
}
this._inited = false;
this._initDroppable(this.$droparea);
}
}
addon(MyElement.prototype, droppable);
window.customElements.define('my-element', MyElement);
dropAreaElement
HTMLElmement
detail
objecttarget
HTMLElmementdataTransfer
DataTransferclientX
numberclientY
numberoffsetX
numberoffsetY
numberdragType
stringdragItems
arraydragOptions
object
detail
objecttarget
HTMLElmementdataTransfer
DataTransfer
detail
objecttarget
HTMLElmementdataTransfer
DataTransferclientX
numberclientY
numberoffsetX
numberoffsetY
numberdragType
stringdragItems
arraydragOptions
object
detail
objecttarget
HTMLElmementdataTransfer
DataTransferclientX
numberclientY
numberoffsetX
numberoffsetY
numberdragType
stringdragItems
arraydragOptions
object