-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathliquid.js
More file actions
23 lines (20 loc) · 747 Bytes
/
Copy pathliquid.js
File metadata and controls
23 lines (20 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const btn = document.getElementById('liquidBtn');
// Magnetic hover
btn.addEventListener("mousemove", (e) => {
const rect = btn.getBoundingClientRect();
const x = e.clientX - (rect.left + rect.width / 2);
const y = e.clientY - (rect.top + rect.height / 2);
btn.style.transform = `translate(${x * 0.15}px, ${y * 0.15}px) scale(1.03)`;
});
btn.addEventListener("mouseleave", () => {
btn.style.transform = "";
});
// Ripple explosion
btn.addEventListener("click", (e) => {
const ripple = document.createElement("span");
ripple.className = "ripple";
ripple.style.left = `${e.clientX}px`;
ripple.style.top = `${e.clientY}px`;
document.body.appendChild(ripple);
setTimeout(() => ripple.remove(), 600);
});