Last active
November 30, 2020 16:56
-
-
Save Explosion-Scratch/a9106fedd9b130c4ebece7ecde6de6d5 to your computer and use it in GitHub Desktop.
Blur with drag and drop
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
javascript: { | |
var x = null; | |
var y = null; | |
rect = null; | |
document.body.style.userSelect = "none"; | |
document.body.style.pointerEvents = "none"; | |
document.addEventListener("mousedown", (e) => { | |
document.addEventListener("mousemove", (e) => { | |
try { | |
rect.remove(); | |
} catch (err) {} | |
rect.style.width = `${e.clientX - x}px`; | |
rect.style.height = `${e.clientY - y}px`; | |
document.body.appendChild(rect); | |
}); | |
x = e.clientX; | |
y = e.clientY; | |
rect = document.createElement("DIV"); | |
rect.style.position = "absolute"; | |
rect.style.top = `${e.clientY}px`; | |
rect.style.left = `${e.clientX}px`; | |
rect.style.backdropFilter = "blur(5px)"; | |
rect.style.width = "20px"; | |
rect.style.height = "20px"; | |
rect.style.zIndex = "1000000000"; | |
}); | |
document.addEventListener("mouseup", (e) => { | |
rect.style.width = `${e.clientX - x}px`; | |
rect.style.height = `${e.clientY - y}px`; | |
document.body.appendChild(rect); | |
rect = null; | |
try { | |
document.removeEventListener("mousemove"); | |
} catch (err) {} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment