forked from jephersonRD/PC-Free
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
135 lines (113 loc) · 4.32 KB
/
index.js
File metadata and controls
135 lines (113 loc) · 4.32 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// ==============================================
// MOBILE MENU TOGGLE
// ==============================================
const menuToggle = document.getElementById('menuToggle');
const navMenu = document.getElementById('navMenu');
menuToggle.addEventListener('click', () => {
navMenu.classList.toggle('active');
const icon = menuToggle.querySelector('i');
if (navMenu.classList.contains('active')) {
icon.classList.remove('bi-list');
icon.classList.add('bi-x');
} else {
icon.classList.remove('bi-x');
icon.classList.add('bi-list');
}
});
// Close menu when clicking on a link
document.querySelectorAll('.nav-link').forEach(link => {
link.addEventListener('click', () => {
navMenu.classList.remove('active');
const icon = menuToggle.querySelector('i');
icon.classList.remove('bi-x');
icon.classList.add('bi-list');
});
});
// ==============================================
// GSAP SCROLL ANIMATIONS
// ==============================================
gsap.registerPlugin(ScrollTrigger);
// Animate all elements with 'reveal-up' class
const revealElements = document.querySelectorAll('.reveal-up');
revealElements.forEach((element) => {
gsap.to(element, {
scrollTrigger: {
trigger: element,
start: 'top 85%',
end: 'bottom 20%',
toggleClass: 'active',
once: true
}
});
});
// ==============================================
// SMOOTH SCROLL FOR ANCHOR LINKS
// ==============================================
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
const offsetTop = target.offsetTop - 70; // Account for fixed header
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
});
});
// ==============================================
// HEADER BACKGROUND ON SCROLL
// ==============================================
const header = document.querySelector('.main-header');
let lastScrollY = window.scrollY;
window.addEventListener('scroll', () => {
const currentScrollY = window.scrollY;
if (currentScrollY > lastScrollY && currentScrollY > header.offsetHeight) {
// Scrolling down
header.classList.add('hidden');
} else {
// Scrolling up
header.classList.remove('hidden');
}
if (currentScrollY > 50) {
header.style.background = 'rgba(18, 18, 18, 0.95)';
} else {
header.style.background = 'rgba(18, 18, 18, 0.8)';
}
lastScrollY = currentScrollY <= 0 ? 0 : currentScrollY; // For Mobile or negative scrolling
});
// ==============================================
// FEATURE CARD HOVER EFFECT
// ==============================================
// ==============================================
// CTA SPOTLIGHT EFFECT
// ==============================================
const ctaSection = document.getElementById('cta-section');
if (ctaSection) {
ctaSection.addEventListener('mousemove', (e) => {
const rect = ctaSection.getBoundingClientRect();
ctaSection.style.setProperty('--x', `${e.clientX - rect.left}px`);
ctaSection.style.setProperty('--y', `${e.clientY - rect.top}px`);
});
}
// ==============================================
// FAQ ACCORDION
// ==============================================
const faqItems = document.querySelectorAll('.faq-item');
faqItems.forEach(item => {
const question = item.querySelector('.faq-question');
const answer = item.querySelector('.faq-answer');
const icon = question.querySelector('i');
question.addEventListener('click', () => {
const isActive = item.classList.contains('active');
item.classList.toggle('active');
icon.classList.toggle('bi-plus-circle');
icon.classList.toggle('bi-dash-circle');
if (item.classList.contains('active')) {
answer.style.maxHeight = answer.scrollHeight + 'px';
} else {
answer.style.maxHeight = '0px';
}
});
});