-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
117 lines (94 loc) · 3.08 KB
/
script.js
File metadata and controls
117 lines (94 loc) · 3.08 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
function hack(value){
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let interval = null;
value.onmouseover = event => {
let iteration = 0;
clearInterval(interval);
interval = setInterval(() => {
event.target.innerText = event.target.innerText
.split("")
.map((letter, index) => {
if(index < iteration) {
return event.target.dataset.value[index];
}
return letters[Math.floor(Math.random() * 26)]
})
.join("");
if(iteration >= event.target.dataset.value.length){
clearInterval(interval);
}
iteration += 1 / 3;
}, 30);
}
}
hack(document.querySelector(".hacker1"));
hack(document.querySelector(".hacker2"));
// ----------------------------------------------
const blob = document.getElementById("blob");
window.onpointermove = event => {
const { clientX, clientY } = event;
blob.animate({
left: `${clientX}px`,
top: `${clientY}px`
}, { duration: 3000, fill: "forwards" });
}
// --------nav------------
const menuItems = document.querySelectorAll('.menu-item');
menuItems.forEach((menuItem) => {
menuItem.addEventListener('click', () => {
menuItems.forEach((item) => {
item.classList.remove('selected');
});
menuItem.classList.add('selected');
});
});
function loaderAnimation() {
var loader = document.querySelector("#loader")
setTimeout(function () {
loader.style.top = "-100%"
}, 4100)
}
loaderAnimation()
function visitcount(){
let visit=document.getElementById("visit");
fetch('https://api.counterapi.dev/v1/ssr/ssr/up')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => visit.innerHTML=data.count)
.catch(error => console.error('There was a problem with the fetch operation:', error));}
visitcount()
// -----------------cursor follower------------
const cursor = document.querySelector('.cursor-follower');
let mouseX = 0; // Actual mouse X position
let mouseY = 0; // Actual mouse Y position
let followerX = 0; // Cursor follower X position
let followerY = 0; // Cursor follower Y position
const delay = 0.1; // Delay factor (lower is slower, higher is faster)
// Mouse movement
document.addEventListener('mousemove', (e) => {
mouseX = e.clientX;
mouseY = e.clientY;
});
// Smooth animation loop
function animateCursor() {
followerX += (mouseX - followerX) * delay;
followerY += (mouseY - followerY) * delay;
cursor.style.transform = `translate(${followerX}px, ${followerY}px) translate(-50%, -50%)`;
requestAnimationFrame(animateCursor); // Continuously update the position
}
// Start the animation loop
animateCursor();
// Hover effect on links
document.querySelectorAll('a').forEach((link) => {
let className = link.classList.contains('no-hover-cursor') ? "shirnk" : "expand";
link.addEventListener('mouseenter', () => {
cursor.classList.add(className);
});
link.addEventListener('mouseleave', () => {
cursor.classList.remove(className);
});
});