34 lines
1.0 KiB
Plaintext
34 lines
1.0 KiB
Plaintext
<script>
|
|
function createEmoji(e: MouseEvent) {
|
|
const emojis = ["🌸", "💖", "✨", "🍬", "🎀", "🍭", "🍡", "🐱", "🍥"];
|
|
const emoji = document.createElement("div");
|
|
emoji.innerText = emojis[Math.floor(Math.random() * emojis.length)];
|
|
emoji.style.position = "fixed";
|
|
emoji.style.left = e.clientX + "px";
|
|
emoji.style.top = e.clientY + "px";
|
|
emoji.style.fontSize = Math.random() * 20 + 10 + "px";
|
|
emoji.style.pointerEvents = "none";
|
|
emoji.style.userSelect = "none";
|
|
emoji.style.zIndex = "9999";
|
|
emoji.style.transition = "all 1s ease-out";
|
|
|
|
// Initial randomness
|
|
const x = (Math.random() - 0.5) * 50;
|
|
const y = (Math.random() - 0.5) * 50;
|
|
|
|
document.body.appendChild(emoji);
|
|
|
|
// Animate
|
|
requestAnimationFrame(() => {
|
|
emoji.style.transform = `translate(${x}px, ${y - 50}px)`;
|
|
emoji.style.opacity = "0";
|
|
});
|
|
|
|
// Cleanup
|
|
setTimeout(() => {
|
|
emoji.remove();
|
|
}, 1000);
|
|
}
|
|
|
|
document.addEventListener("click", createEmoji);
|
|
</script> |