Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
103 lines (88 loc) · 3.16 KB
/
Copy pathscript.js
File metadata and controls
103 lines (88 loc) · 3.16 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const nextBtn = document.querySelector('.next-btn');
const video = document.querySelector('.hero-video');
const movieList = ['videos/hero-1.mp4', 'videos/hero-2.mp4', 'videos/hero-3.mp4', 'videos/hero-4.mp4'];
let index = 0;
nextBtn.addEventListener('click', function(){
index++;
video.src = movieList[index];
if(index === 3){
index =-1;
}
})
// Mobile Menu Toggle
window.addEventListener('load', function() {
const preloader = document.getElementById('preloader');
if (preloader) {
preloader.classList.add('loaded');
// Remove from DOM after transition
setTimeout(() => {
preloader.style.display = 'none';
}, 800);
}
});
document.addEventListener('DOMContentLoaded', function() {
const mobileMenuToggle = document.getElementById('mobileMenuToggle');
const mainHeader = document.getElementById('mainHeader');
const headRight = document.querySelector('.head-right');
if (mobileMenuToggle) {
mobileMenuToggle.addEventListener('click', function() {
mainHeader.classList.toggle('mobile-open');
headRight.classList.toggle('active');
// Change icon
const icon = this.querySelector('i');
if (headRight.classList.contains('active')) {
icon.className = 'bx bx-x';
} else {
icon.className = 'bx bx-menu';
}
});
}
// Close mobile menu when clicking on a link
const navLinks = document.querySelectorAll('.head-right a');
navLinks.forEach(link => {
link.addEventListener('click', function() {
if (window.innerWidth <= 480) {
mainHeader.classList.remove('mobile-open');
headRight.classList.remove('active');
const icon = mobileMenuToggle.querySelector('i');
icon.className = 'bx bx-menu';
}
});
});
// Handle window resize
window.addEventListener('resize', function() {
if (window.innerWidth > 480) {
mainHeader.classList.remove('mobile-open');
headRight.classList.remove('active');
if (mobileMenuToggle) {
const icon = mobileMenuToggle.querySelector('i');
icon.className = 'bx bx-menu';
}
}
});
});
// Smooth scroll for anchor links (optional enhancement)
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Add scroll-based header styling (optional enhancement)
let lastScroll = 0;
window.addEventListener('scroll', function() {
const header = document.getElementById('mainHeader');
const currentScroll = window.pageYOffset;
if (currentScroll > 100) {
header.style.padding = '8px 40px';
} else {
header.style.padding = '10px 40px';
}
lastScroll = currentScroll;
});