-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
28 lines (25 loc) · 1.02 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
document.addEventListener("DOMContentLoaded", function () {
// Email button
const btn = document.getElementById("copyEmailBtn");
const tooltip = document.getElementById("tooltip");
btn.addEventListener("click", function () {
navigator.clipboard.writeText("hola@jorgeteixeira.es")
.then(() => {
// Show tooltip
tooltip.classList.remove("invisible");
tooltip.classList.add("opacity-100");
// Hide tooltip after 2 seconds with fade-out animation
setTimeout(() => {
tooltip.classList.remove("opacity-100");
tooltip.classList.add("opacity-0");
// Actually hide it after animation
setTimeout(() => {
tooltip.classList.add("invisible");
}, 300);
}, 2000);
})
.catch(err => {
console.error("Could not copy email: ", err);
});
});
});