-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscripts.js
70 lines (60 loc) · 2.59 KB
/
scripts.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
// Create the custom cursor element
const cursor = document.createElement('div');
cursor.classList.add('cursor');
document.body.appendChild(cursor);
// Move the cursor element based on mouse movement
document.addEventListener('mousemove', (e) => {
cursor.style.left = `${e.pageX - cursor.offsetWidth / 2}px`; // Adjust to center cursor
cursor.style.top = `${e.pageY - cursor.offsetHeight / 2}px`; // Adjust to center cursor
});
// Change the cursor color and size when hovering over clickable elements
document.querySelectorAll('a, button, .cta-button, .option-icon').forEach((element) => {
element.addEventListener('mouseenter', () => {
cursor.style.backgroundColor = '#ffffff'; // Change to white on hover
cursor.style.width = '40px'; // Increase size
cursor.style.height = '40px'; // Increase size
});
element.addEventListener('mouseleave', () => {
cursor.style.backgroundColor = '#ff6600'; // Revert to neon orange
cursor.style.width = '20px'; // Revert size
cursor.style.height = '20px'; // Revert size
});
});
// Open and close the full-page menu
const optionIcon = document.getElementById('hero-content');
const fullPageMenu = document.getElementById('full-page-menu');
const closeButton = document.getElementById('close-button');
const menuOptions = document.querySelectorAll('.menu-option');
// Open full-page menu
optionIcon.addEventListener('click', () => {
fullPageMenu.classList.toggle('open');
});
// Close full-page menu
closeButton.addEventListener('click', () => {
fullPageMenu.classList.remove('open');
});
// Navigate to a new page on clicking a menu option
menuOptions.forEach(option => {
option.addEventListener('click', () => {
const link = option.dataset.link; // Get the link from the data attribute
if (link) {
window.location.href = link;
}
});
});
// Scroll handling for About section reveal
window.addEventListener('scroll', function () {
const aboutSection = document.querySelector('#about');
const windowHeight = window.innerHeight;
const sectionTop = aboutSection.getBoundingClientRect().top;
// If the About section is within the viewable area, make it visible
if (sectionTop < windowHeight - 150) {
aboutSection.classList.add('visible');
}
});
// Scroll handling for background video
window.addEventListener('scroll', function () {
const video = document.getElementById('background-video');
const videoOffset = window.pageYOffset / 2; // Controls how fast the video scrolls
video.style.transform = `translateY(${videoOffset}px)`;
});