-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
60 lines (50 loc) · 1.42 KB
/
Copy pathscript.js
File metadata and controls
60 lines (50 loc) · 1.42 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Untuk membuat link bisa dicopy
*/
const actionLink = document.querySelectorAll(".link-card .link-action");
actionLink.forEach((action) => {
action.addEventListener("click", (e) => {
e.preventDefault();
navigator.clipboard.writeText(action.parentElement.getAttribute("href"));
/**
* Untuk memunculkan toast notification
*/
document.getElementById("toast").innerHTML = `
<div class="toast-container">
<p>✅ Link <strong> ${action.parentElement.innerText} </strong> berhasil disalin!</p>
</div>
`;
/**
* Untuk menghilangkan toast notification
*/
setTimeout(() => {
document
.querySelector("#toast .toast-container")
.classList.add("toast-gone");
}, 300);
setTimeout(() => {
document.querySelector("#toast .toast-container").remove();
}, 2000);
});
});
/**
* Untuk ganti icon sosmed saat hover
*/
document.querySelectorAll(".sosmed i").forEach((sosmed) => {
sosmed.addEventListener("mouseenter", () => {
sosmed.classList.remove("ph");
sosmed.classList.add("ph-fill");
});
sosmed.addEventListener("mouseleave", () => {
sosmed.classList.remove("ph-fill");
sosmed.classList.add("ph");
});
});
/**
* Animasi Text bergerak saat scroll
*/
document.addEventListener("scroll", (e) => {
document.querySelector(".bg-text-animation").style.transform = `translateX(${
window.scrollY / 5
}px)`;
});