-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
33 lines (29 loc) · 882 Bytes
/
script.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
// Detect when an object is shown and play the transition
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
//console.log(entry);
if (entry.isIntersecting) {
entry.target.classList.add('show');
setTimeout(() => { entry.target.classList.add('fast-transition'); }, 1000)
}
});
});
const hiddenElements = document.querySelectorAll('.hidden');
hiddenElements.forEach((el) => observer.observe(el));
// Parallax effect
console.log(navigator.userAgent);
if(navigator.userAgent.includes('Safari')) {
console.log('Safari');
setInterval(() => {
document.body.style.backgroundPosition = '0%' + window.scrollY/500 +'%';
},
5
);
} else {
console.log('other device');
setInterval(() => {
document.body.style.backgroundPosition = '0%' + window.scrollY/5 +'%';
},
30
);
}