-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
107 lines (90 loc) · 3.38 KB
/
Copy pathscript.js
File metadata and controls
107 lines (90 loc) · 3.38 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
// Scroll Animation Observer with proper timing
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
// Intersection Observer for smooth reveal animations
const revealObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('active');
}
});
}, observerOptions);
document.addEventListener('DOMContentLoaded', () => {
// Add reveal class to elements that should animate on scroll
const elementsToAnimate = document.querySelectorAll(
'.intro-title, .intro-text p, .platform-title, .platform-text p, ' +
'.projects-title, .project-card, .advantage-title, .advantage-item, .tech-cta'
);
elementsToAnimate.forEach(el => {
el.classList.add('reveal');
revealObserver.observe(el);
});
// Hero Section - Initial animations
const heroElements = document.querySelectorAll(
'.hero-subtitle, .hero-title, .hero-desc'
);
heroElements.forEach((el, index) => {
el.style.opacity = '1';
el.style.animation = `fadeInUp 0.8s ease-out ${index * 0.1}s forwards`;
});
});
// Floating tech icons - enhanced animation with random offsets
const techIcons = document.querySelectorAll('.tech-icon');
techIcons.forEach((icon, i) => {
const randomDelay = -(Math.random() * 6);
const randomDuration = 5 + Math.random() * 4;
icon.style.animationDelay = `${randomDelay}s`;
icon.style.animationDuration = `${randomDuration}s`;
});
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
const target = document.querySelector(this.getAttribute('href'));
if (target) {
e.preventDefault();
target.scrollIntoView({ behavior: 'smooth' });
}
});
});
// Unified Hero Section scroll animation
const heroContent = document.querySelector('.hero-content');
const scrollIndicator = document.querySelector('.scroll-indicator');
const navbar = document.querySelector('.navbar');
window.addEventListener('scroll', () => {
const scrollY = window.scrollY;
const heroHeight = window.innerHeight;
const scrollProgress = Math.min(scrollY / (heroHeight * 0.5), 1);
const translateY = scrollY * 0.8;
if (heroContent) {
heroContent.style.transform = `translateY(-${translateY}px)`;
heroContent.style.opacity = Math.max(0, 1 - scrollProgress);
}
if (navbar) {
navbar.style.transform = `translateY(-${translateY}px)`;
navbar.style.opacity = Math.max(0, 1 - scrollProgress);
}
if (scrollIndicator) {
scrollIndicator.style.transform = `translateY(-${translateY}px)`;
scrollIndicator.style.opacity = Math.max(0, 1 - scrollProgress);
}
});
// Sticky CTA Button logic
const scrollToTopButton = document.querySelector('.sticky-cta');
const ctaSection = document.querySelector('.tech-cta');
window.addEventListener('scroll', () => {
if (!scrollToTopButton || !ctaSection) return;
const ctaRect = ctaSection.getBoundingClientRect();
const windowHeight = window.innerHeight;
if (ctaRect.top < windowHeight) {
scrollToTopButton.style.opacity = '0';
scrollToTopButton.style.pointerEvents = 'none';
} else if (window.scrollY > 300) {
scrollToTopButton.style.opacity = '1';
scrollToTopButton.style.pointerEvents = 'auto';
} else {
scrollToTopButton.style.opacity = '0.7';
scrollToTopButton.style.pointerEvents = 'auto';
}
});