-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
20 lines (17 loc) · 892 Bytes
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
window.addEventListener("scroll", (e)=>{
let noStickyOffset = document.body.clientHeight*4;
let scrolled = document.body.scrollTop / noStickyOffset;
let $pink = document.querySelector(".pink");
let $purple = document.querySelector(".purple");
let $orange = document.querySelector(".orange");
let $blue = document.querySelector(".blue");
$pink.style.clipPath = `inset(${((0.25-scrolled)/0.25)*100}% 0px 0px 0px)`;
$purple.style.clipPath = `inset(${((0.5-scrolled)/0.25)*100}% 0px 0px 0px)`;
$orange.style.clipPath = `inset(${((0.75-scrolled)/0.25)*100}% 0px 0px 0px)`;
$blue.style.clipPath = `inset(${((1-scrolled)/0.25)*100}% 0px 0px 0px)`;
if(scrolled>=1) {
document.querySelector(".sticky-container").classList.add("no-sticky");
} else {
document.querySelector(".sticky-container").classList.remove("no-sticky");
}
})