Skip to content

Instantly share code, notes, and snippets.

@nexpr
Created November 13, 2016 18:04
Show Gist options
  • Select an option

  • Save nexpr/d96a85648ee744790cc82fbe4e906c5f to your computer and use it in GitHub Desktop.

Select an option

Save nexpr/d96a85648ee744790cc82fbe4e906c5f to your computer and use it in GitHub Desktop.
fullscreen drop supporter
body{
margin: 0;
}
.droparea{
all: initial;
position: fixed;
z-index: 1000;
width: 100%;
height: 100%;
box-sizing: border-box;
display: none;
}
.droparea.active{
display: block;
border: 8px dashed purple;
}
!function(){
var droparea = document.createElement("div")
droparea.className = "droparea"
function showDroparea(){
droparea.classList.add("active")
}
function hideDroparea(){
droparea.classList.remove("active")
}
droparea.ondragleave = eve => {
eve.preventDefault()
hideDroparea()
}
window.addEventListener("dragover", eve => eve.preventDefault(), false)
window.addEventListener("dragenter", eve => {
eve.preventDefault()
showDroparea()
}, false)
window.addEventListener("drop", eve => {
eve.preventDefault()
hideDroparea()
}, false)
document.body.appendChild(droparea)
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment