-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
93 lines (81 loc) · 3.11 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
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
document.addEventListener('DOMContentLoaded', () => {
// Landing page animation
const landingPage = document.getElementById('landing-page');
const enterSiteButton = document.getElementById('enter-site');
const mainContent = document.querySelector('main');
enterSiteButton.addEventListener('click', () => {
landingPage.classList.add('fade-out');
setTimeout(() => {
landingPage.style.display = 'none';
mainContent.classList.add('fade-in');
}, 1000);
});
// Smooth scrolling
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Reveal sections on scroll
const revealSections = () => {
const sections = document.querySelectorAll('section');
sections.forEach(section => {
const sectionTop = section.getBoundingClientRect().top;
const windowHeight = window.innerHeight;
if (sectionTop < windowHeight * 0.75) {
section.classList.add('visible');
}
});
};
window.addEventListener('scroll', revealSections);
window.addEventListener('load', revealSections);
// Parallax effect for header
const header = document.querySelector('header');
window.addEventListener('scroll', () => {
const scrollPosition = window.pageYOffset;
header.style.backgroundPositionY = `${scrollPosition * 0.5}px`;
});
// Typing effect for landing page title
const landingTitle = document.querySelector('.landing-page h1');
const originalText = landingTitle.textContent;
landingTitle.textContent = '';
let i = 0;
const typeWriter = () => {
if (i < originalText.length) {
landingTitle.textContent += originalText.charAt(i);
i++;
setTimeout(typeWriter, 100);
}
};
typeWriter();
// Music player functionality
const audioPlayer = document.getElementById('audio-player');
const playPauseBtn = document.getElementById('play-pause-btn');
const seekBar = document.getElementById('seek-bar');
playPauseBtn.addEventListener('click', () => {
if (audioPlayer.paused) {
audioPlayer.play();
playPauseBtn.textContent = 'Pause';
} else {
audioPlayer.pause();
playPauseBtn.textContent = 'Play';
}
});
audioPlayer.addEventListener('timeupdate', () => {
const progress = (audioPlayer.currentTime / audioPlayer.duration) * 100;
seekBar.value = progress;
});
seekBar.addEventListener('input', () => {
const time = (seekBar.value / 100) * audioPlayer.duration;
audioPlayer.currentTime = time;
});
// Mobile menu toggle
const menuToggle = document.getElementById('menu-toggle');
const nav = document.querySelector('nav');
menuToggle.addEventListener('click', () => {
nav.classList.toggle('active');
});
});