Last active
December 19, 2017 06:30
-
-
Save bojicas/5fc7463b77110cd0e5f47a347c686bfe to your computer and use it in GitHub Desktop.
Prevent drag & drop outside dropzone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dropzoneId = 'dropzone' | |
window.addEventListener('dragover', e => { | |
e = e || event | |
if (e.target.id !== dropzoneId) { | |
e.preventDefault() | |
} | |
}) | |
window.addEventListener('drop', e => { | |
e = e || event | |
if (e.target.id !== dropzoneId) { | |
e.preventDefault() | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment