-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcursor.js
50 lines (41 loc) · 1.41 KB
/
cursor.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
39
40
41
42
43
44
45
46
47
48
49
50
let cursor = document.querySelector('.cursor');
let astronomy = document.querySelector('.astronomy');
let environment = document.querySelector('.environment');
let video = document.querySelector('.video');
let navbar_links = document.querySelectorAll('.navbar a');
window.addEventListener('mousemove', function(e) {
cursor.animate({
top:e.pageY + 'px',
left:e.pageX + 'px'
}, {duration:1000, fill:'forwards'});
});
astronomy.addEventListener('mouseenter', function() {
cursor.style.background = 'white';
})
environment.addEventListener('mouseenter', function() {
cursor.style.background = 'white';
})
video.addEventListener('mouseenter', function() {
cursor.style.background = 'white';
})
astronomy.addEventListener('mouseleave', function() {
cursor.style.background = 'black';
})
environment.addEventListener('mouseleave', function() {
cursor.style.background = 'black';
})
video.addEventListener('mouseleave', function() {
cursor.style.background = 'black';
})
window.addEventListener('scroll', function(e) {
if (((this.window.scrollY / this.window.innerHeight) > 2) && ((this.window.scrollY / this.window.innerHeight) < 5)) {
navbar_links.forEach(link => {
link.style.color = 'white';
})
}
else {
navbar_links.forEach(link => {
link.style.color = 'black';
})
}
});