Skip to content

Instantly share code, notes, and snippets.

@Explosion-Scratch
Last active November 30, 2020 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Explosion-Scratch/a9106fedd9b130c4ebece7ecde6de6d5 to your computer and use it in GitHub Desktop.
Save Explosion-Scratch/a9106fedd9b130c4ebece7ecde6de6d5 to your computer and use it in GitHub Desktop.
Blur with drag and drop
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