-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
38 lines (33 loc) · 1.21 KB
/
index.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
29
30
31
32
33
34
35
36
37
38
var colors = { default: 'rgba(237, 135, 150, 0.2)', hover: 'rgba(138, 173, 244, 0.6)' };
const fadeElements = document.querySelectorAll('.fade');
const cursor = document.querySelector('.cursor');
fadeElements.forEach((fadeElement, index) => {
fadeElement.style.animationDelay = `${index * 1}s`;
});
window.addEventListener('mousemove', function (e) {
if (window.innerWidth >= 512) {
cursor.style.display = 'block';
cursor.style.top = `${e.pageY - cursor.clientWidth / 2}px`;
cursor.style.left = `${e.pageX - cursor.clientHeight / 2}px`;
} else {
cursor.style.display = 'none';
}
});
window.addEventListener('mouseover', function (e) {
const classList = e.target.classList;
if (e.target.tagName === 'A' || classList.contains('info')) {
cursor.style.background = colors.hover;
cursor.style.transform = 'scale(1)';
} else {
cursor.style.background = colors.default;
cursor.style.transform = 'scale(0.8)';
}
});
window.addEventListener('mousedown', function (e) {
cursor.style.background = colors.hover;
cursor.style.transform = 'scale(1)';
});
window.addEventListener('mouseup', function (e) {
cursor.style.background = colors.default;
cursor.style.transform = 'scale(0.8)';
});