mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-11-17 21:33:16 +08:00
26 lines
648 B
JavaScript
26 lines
648 B
JavaScript
|
const DragAndDrop = {
|
||
|
mounted() {
|
||
|
const dropZone = this.el.querySelector("[data-dropzone]");
|
||
|
|
||
|
["dragenter", "dragover"].forEach((eventName) => {
|
||
|
dropZone.addEventListener(eventName, highlight, false);
|
||
|
});
|
||
|
|
||
|
["dragleave", "drop"].forEach((eventName) => {
|
||
|
dropZone.addEventListener(eventName, unhighlight, false);
|
||
|
});
|
||
|
|
||
|
function highlight(e) {
|
||
|
dropZone.classList.add("bg-red-200");
|
||
|
dropZone.classList.add("border-red-400");
|
||
|
}
|
||
|
|
||
|
function unhighlight(e) {
|
||
|
dropZone.classList.remove("bg-red-200");
|
||
|
dropZone.classList.remove("border-red-400");
|
||
|
}
|
||
|
},
|
||
|
};
|
||
|
|
||
|
export default DragAndDrop;
|