mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-02-22 05:48:31 +08:00
* Restructure hook files * Simplify app.js * Refactor hooks * Implement password toggle with JS commands
24 lines
565 B
JavaScript
24 lines
565 B
JavaScript
const DRAGGING_ATTR = "data-js-dragging";
|
|
|
|
/**
|
|
* A hook used to highlight drop zone when dragging a file.
|
|
*/
|
|
const Dropzone = {
|
|
mounted() {
|
|
this.el.addEventListener("dragenter", (event) => {
|
|
this.el.setAttribute(DRAGGING_ATTR, "");
|
|
});
|
|
|
|
this.el.addEventListener("dragleave", (event) => {
|
|
if (!this.el.contains(event.relatedTarget)) {
|
|
this.el.removeAttribute(DRAGGING_ATTR);
|
|
}
|
|
});
|
|
|
|
this.el.addEventListener("drop", (event) => {
|
|
this.el.removeAttribute(DRAGGING_ATTR);
|
|
});
|
|
},
|
|
};
|
|
|
|
export default Dropzone;
|