-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
22 lines (19 loc) · 862 Bytes
/
script.js
File metadata and controls
22 lines (19 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Get references to the elements
const stars = document.getElementById('stars');
const mountains_behind = document.getElementById('mountains_behind');
const text = document.getElementById('text');
const mountains_front = document.getElementById('mountains_front');
const header = document.querySelector('header');
// Add scroll event listener
window.addEventListener('scroll', function() {
// Get the current scroll position
let value = window.scrollY;
// Update element styles based on scroll position
stars.style.left = value * 0.25 + 'px';
mountains_behind.style.top = value * 0.5 + 'px';
mountains_front.style.top = value * 0 + 'px';
text.style.marginRight = value * 4 + 'px';
text.style.marginTop = value * 1.5 + 'px';
logoku.style.marginTop = value * 1.5 + 'px';
header.style.top = value * 0.5 + 'px';
});