Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tanepiper
Created January 31, 2018 17:44
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 tanepiper/c2e1aa48042f464f1ed41d6206518c70 to your computer and use it in GitHub Desktop.
Save tanepiper/c2e1aa48042f464f1ed41d6206518c70 to your computer and use it in GitHub Desktop.
Creates an annoying button it's hard to close with a mouse
function createModal() {
// ...
const button = document.createElement("button");
button.innerText = "Close Me";
function moveModal() {
button.setAttribute("disabled", true);
button.innerText = 'LOL';
lastX = newModal.style.top || 0;
lastY = newModal.style.left || 0;
newModal.style.transform = `translate(${(lastX * Math.random() < 0.5
? -1
: 1) +
Math.random() * 250}px, ${(lastY * Math.random() < 0.5 ? -1 : 1) +
Math.random() * 250}px)`;
button.removeAttribute("disabled");
}
button.addEventListener('mouseenter', moveModal);
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment