-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
49 lines (41 loc) · 1.75 KB
/
main.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
const parallaxOneLayerOne = document.querySelector('.parallax-one-layer-one');
const parallaxOneLayerThree = document.querySelector(
'.parallax-one-layer-three'
);
const parallaxOneLayerFour = document.querySelector('.parallax-one-layer-four');
const parallaxOneLayerFive = document.querySelector('.parallax-one-layer-five');
const parallaxOneLayerSix = document.querySelector('.parallax-one-layer-six');
const parallaxTwoLayerOne = document.querySelector('.parallax-two-layer-one');
const parallaxTwoLayerTwo = document.querySelector('.parallax-two-layer-two');
const parallaxTwoLayerThree = document.querySelector(
'.parallax-two-layer-three'
);
const parallaxTwoLayerFour = document.querySelector('.parallax-two-layer-four');
const parallaxTwoLayerFive = document.querySelector('.parallax-two-layer-five');
document.addEventListener('scroll', () => {
const scrollPosition = window.scrollY;
parallaxOneLayerOne.style.transform = `translateY(${scrollPosition * 0.1}px)`;
parallaxOneLayerThree.style.transform = `translateY(-${
scrollPosition * 0.015
}px)`;
parallaxOneLayerFour.style.transform = `translateY(${
scrollPosition * 0.7
}px)`;
parallaxOneLayerFive.style.transform = `translate(${scrollPosition * 0.2}px)`;
parallaxOneLayerSix.style.transform = `translate(-${scrollPosition * 0.3}px)`;
parallaxTwoLayerOne.style.transform = `translateY(${
scrollPosition * 0.06
}px)`;
parallaxTwoLayerTwo.style.transform = `translateY(${
scrollPosition * 0.06
}px)`;
parallaxTwoLayerThree.style.transform = `translateY(${
scrollPosition * 0.1
}px)`;
parallaxTwoLayerFour.style.transform = `translateY(${
scrollPosition * 0.03
}px)`;
parallaxTwoLayerFive.style.transform = `translateY(-${
scrollPosition * 0.018
}px)`;
});