Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

Commit

Permalink
Prevent loading image if dropped outside dropZone
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysdz committed May 19, 2018
1 parent 1b6217c commit c899ca4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,21 @@ function savePattern(e){
document.getElementById("savePattern").addEventListener("click", savePattern);
document.getElementById("savePatternOnly").addEventListener("click", savePattern);

/**
* Prevent opening loading image if dropped outside `dropZone`
* @param {DragEvent} e
*/
function preventDrop(e){
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = "none";
}
document.body.addEventListener("dragenter", preventDrop);
document.body.addEventListener("dragover", preventDrop);
document.body.addEventListener("dragleave", preventDrop);
document.body.addEventListener("dragend", preventDrop);
document.body.addEventListener("drop", preventDrop);

/**
* Show the copy icon when dragging over. Shows dropzone
* @param {DragEvent} e
Expand Down

0 comments on commit c899ca4

Please sign in to comment.