-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
58 lines (40 loc) · 1.52 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// for menubar
const toggleBtn = document.querySelector(".toggle_btn");
const toggleBtnIcon = document.querySelector(".toggle_btn i");
const dropDownMenu = document.querySelector(".dropdown_menu");
toggleBtn.onclick = function () {
dropDownMenu.classList.toggle("open")
const isOpen = dropDownMenu.classList.contains('open')
toggleBtnIcon.classList = isOpen
? 'fa-solid fa-xmark'
: 'fa-solid fa-bars'
}
// navbar progress
const scrollProgress = document.getElementById('scroll-progress');
const height =
document.documentElement.scrollHeight - document.documentElement.clientHeight;
window.addEventListener('scroll', () => {
const scrollTop =
document.body.scrollTop || document.documentElement.scrollTop;
scrollProgress.style.width = `${(scrollTop / height) * 100}%`;
});
// btn smooth scroll
document.getElementById('home').addEventListener('click', function (e) {
e.preventDefault();
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
document.getElementById('home').addEventListener('click', function (e) {
// Handle your logic for going back
});
// poster changes
document.addEventListener("DOMContentLoaded", function () {
let image = document.getElementById('image');
let images = ['images/poster_1.jpg', 'images/poster_2.jpg', 'images/poster_3.jpg', 'images/poster_4.jpg', 'images/poster_5.jpg'];
setInterval(function () {
let random = Math.floor(Math.random() * 5);
image.src = images[random];
}, 5000);
});