-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
56 lines (38 loc) · 1.31 KB
/
Copy pathscript.js
File metadata and controls
56 lines (38 loc) · 1.31 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
// moving eyes
document.addEventListener('mousemove', (e) => {
const mouseX = e.clientX;
const mouseY = e.clientY;
const anchor = document.getElementById('anchor');
const rekt = anchor.getBoundingClientRect();
const anchorX = rekt.left + rekt.width/2;
const anchorY = rekt.top + rekt.width/2;
const angleDeg = angle(mouseX, mouseY, anchorX, anchorY);
console.log(angleDeg);
const eyes = document.querySelectorAll('.eye');
eyes.forEach(eye => {
eye.style.transform = `rotate(${-30 + angleDeg}deg)`
})
})
function angle (cx, cy, ex, ey) {
const dy = ey-cy;
const dx = ex-cx;
const rad = Math.atan2(dy, dx);
const deg = rad * 180 / Math.PI;
return deg;
}
// About Me Page
// ------------------------------------------------------------------------------
let tablinks = document.getElementsByClassName("tab-links");
let tabcontents = document.getElementsByClassName("tab-contents");
function opentab(tabname) {
for(tablink of tablinks) {
tablink.classList.remove("active-link");
}
for(tabcontent of tabcontents) {
tabcontent.classList.remove("active-tab");
}
event.currentTarget.classList.add("active-link");
document.getElementById(tabname).classList.add("active-tab")
}
// portfolio
// ------------------------------------------------------------------------------