webamp/packages/webamp-modern/src/dropTarget.ts
Fathony Luthfillah 10555e093f
Set the 2nd modern iteration as only one on (modern) track. (#1166)
* yarn extract-object-types (run again)

* preparing to load Application.mi

* avoid error about using function ins strict mode.
turn this to "function" syntax to see the error/warn

* embed TrueTypeFont in one CSS

* add api: getAttribute

* reaching zero erro at devtool Console

* set color correctly.

* move compiler to new project

* take some yarn-scripts from sibling (modern-1)

* reconfigure objectData target path

* remove duplicated folder

* discontinuing the 1st iteration
captbaritone: it's probably time to del modern & ren modern-2: modern

* set the 2nd iteration as only one on track.
captbaritone: it's probably time to del modern & ren modern-2: modern

* bugfix test not working: path unavailable

* implement TODO

* reduce warning at import jzip

* solving Deploy: failed

* solving deploy failed
error: Unknown workspace "webamp-modern

* bugfix premateur call of this._font_id

* bugfix font-family : ''; prettier.

Co-authored-by: Fathony <fathony@smart-leaders.net>
2022-03-30 19:35:19 -07:00

36 lines
1 KiB
TypeScript

export function addDropHandler(onDrop: (blob: Blob) => void) {
const dropTarget = document.createElement("div");
dropTarget.style.top = "0px";
dropTarget.style.left = "0px";
dropTarget.style.position = "absolute";
dropTarget.style.bottom = "0";
dropTarget.style.right = "0";
document.body.appendChild(dropTarget);
function dropHandler(ev: DragEvent) {
// Prevent default behavior (Prevent file from being opened)
ev.preventDefault();
const file = ev.dataTransfer.files[0];
if (file == null) {
return;
}
clearDropTargetStyle();
onDrop(file);
}
function clearDropTargetStyle() {
dropTarget.style.border = "none";
}
function dragOverHandler(ev: DragEvent) {
dropTarget.style.border = "4px dotted white";
// Prevent default behavior (Prevent file from being opened)
ev.preventDefault();
}
dropTarget.addEventListener("dragover", dragOverHandler);
dropTarget.addEventListener("dragleave", clearDropTargetStyle);
dropTarget.addEventListener("drop", dropHandler);
}