- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
Latest commit
32 lines (25 loc) · 744 Bytes
/
Copy pathscript.js
File metadata and controls
32 lines (25 loc) · 744 Bytes
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
constheader=document.querySelector("[data-header]");
constyear=document.querySelector("[data-year]");
constheroImage=document.querySelector(".hero-image");
if(year){
year.textContent=newDate().getFullYear();
}
constupdateHeader=()=>{
if(!header){
return;
}
header.classList.toggle("is-scrolled",window.scrollY>24);
};
constupdateHero=()=>{
if(!heroImage||window.matchMedia("(prefers-reduced-motion: reduce)").matches){
return;
}
constoffset=Math.min(window.scrollY*0.08,28);
heroImage.style.transform=`scale(1.03) translateY(${offset}px)`;
};
updateHeader();
updateHero();
window.addEventListener("scroll",()=>{
updateHeader();
updateHero();
},{passive: true});