-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
82 lines (73 loc) · 2.54 KB
/
Copy pathmain.js
File metadata and controls
82 lines (73 loc) · 2.54 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
const root = document.querySelector(":root");
var scrollvalue = window.scrollY;
var scrollindex = 0;
var scrollanchors = [];
getSize();
getscrollIndex();
let main = document.getElementById('main');
let mainoffsetX=540;
let mainoffsetY=40;
const onMouseMove = (e) =>{
main.style.left = (e.pageX-mainoffsetX) + 'px';
main.style.top = (e.pageY-mainoffsetY) + 'px';
}
document.addEventListener('mousemove', onMouseMove);
function getSize() {
const width = window.innerWidth;
const height = window.innerHeight;
root.style.setProperty("--pseudo-width", width+"px");
root.style.setProperty("--pseudo-height", height+"px");
//resize scroll anchors
for (i=0;i<3;i++){
scrollanchors[i]=(height*i)-(height*0.33);
}
console.log(scrollanchors);
if (width<=1140){
document.getElementById("rightbar").classList.add("hidden")
} else {
document.getElementById("rightbar").classList.remove("hidden")
}
if (width<=1640){
document.getElementById("rightbar2").classList.add("hidden")
} else {
document.getElementById("rightbar2").classList.remove("hidden")
}
}
function showSection(){
for (i=0;i<3;i++){
let section="content"+i;
if (i==scrollindex) {
console.log(section+" is shown");
document.getElementById(section).classList.add('show');
if (i==0){
document.getElementById('wrapper0').classList.add('show');
}
} else {
console.log(section+" is hidden");
document.getElementById(section).classList.remove('show');
document.getElementById('wrapper0').classList.add('show');
}
}
}
function getscrollIndex(){
let s = Math.trunc(scrollvalue/scrollanchors[1]);
console.log ("scroll index is: "+s)
scrollindex = s;
showSection();
}
function getScrollValue() {
scrollvalue = window.scrollY;
console.log("scroll: "+scrollvalue);
root.style.setProperty("--pseudo-scroll", scrollvalue*0.6+"px");
getscrollIndex();
}
window.addEventListener("resize", getSize);
window.addEventListener("scroll",getScrollValue)
const mousePosText = document.getElementById('mouse-pos');
let mousePos = { x: undefined, y: undefined };
window.addEventListener('mousemove', (event) => {
mousePos = { x: event.clientX, y: event.clientY };
root.style.setProperty("--pseudo-mouseX", mousePos.x);
root.style.setProperty("--pseudo-mouse", mousePos.x);
console.log(mousePos);
});