-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
134 lines (117 loc) · 4.18 KB
/
Copy pathscript.js
File metadata and controls
134 lines (117 loc) · 4.18 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
// Smooth scroll for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
const navHeight = document.querySelector('.top-nav').offsetHeight;
const targetPosition = target.offsetTop - navHeight;
window.scrollTo({
top: targetPosition,
behavior: 'smooth'
});
}
});
});
// Add active state to nav links based on scroll position
const sections = document.querySelectorAll('section[id]');
const navLinks = document.querySelectorAll('.nav-link');
function updateActiveNavLink() {
const scrollPosition = window.scrollY + 100;
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.offsetHeight;
const sectionId = section.getAttribute('id');
if (scrollPosition >= sectionTop && scrollPosition < sectionTop + sectionHeight) {
navLinks.forEach(link => {
link.style.color = '';
if (link.getAttribute('href') === `#${sectionId}`) {
link.style.color = 'var(--color-primary)';
}
});
}
});
}
window.addEventListener('scroll', updateActiveNavLink);
window.addEventListener('load', updateActiveNavLink);
// Animate stats on scroll
const observerOptions = {
threshold: 0.5,
rootMargin: '0px 0px -100px 0px'
};
const statsObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe stat items
document.querySelectorAll('.stat-item').forEach(stat => {
stat.style.opacity = '0';
stat.style.transform = 'translateY(20px)';
stat.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
statsObserver.observe(stat);
});
// Observe feature cards
document.querySelectorAll('.feature-card').forEach((card, index) => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = `opacity 0.6s ease ${index * 0.1}s, transform 0.6s ease ${index * 0.1}s`;
statsObserver.observe(card);
});
// Observe methodology cards
document.querySelectorAll('.methodology-card').forEach((card, index) => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = `opacity 0.6s ease ${index * 0.1}s, transform 0.6s ease ${index * 0.1}s`;
statsObserver.observe(card);
});
// Add scroll-to-top functionality
let scrollToTopBtn = document.createElement('button');
scrollToTopBtn.innerHTML = '↑';
scrollToTopBtn.className = 'scroll-to-top';
scrollToTopBtn.style.cssText = `
position: fixed;
bottom: 32px;
right: 32px;
width: 48px;
height: 48px;
border-radius: 50%;
background-color: var(--color-primary);
color: var(--color-on-primary);
border: none;
font-size: 24px;
cursor: pointer;
opacity: 0;
visibility: hidden;
transition: opacity 0.3s, visibility 0.3s, background-color 0.2s;
z-index: 999;
box-shadow: 0 4px 12px rgba(20, 20, 19, 0.15);
`;
document.body.appendChild(scrollToTopBtn);
window.addEventListener('scroll', () => {
if (window.scrollY > 500) {
scrollToTopBtn.style.opacity = '1';
scrollToTopBtn.style.visibility = 'visible';
} else {
scrollToTopBtn.style.opacity = '0';
scrollToTopBtn.style.visibility = 'hidden';
}
});
scrollToTopBtn.addEventListener('click', () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
scrollToTopBtn.addEventListener('mouseenter', () => {
scrollToTopBtn.style.backgroundColor = 'var(--color-primary-active)';
});
scrollToTopBtn.addEventListener('mouseleave', () => {
scrollToTopBtn.style.backgroundColor = 'var(--color-primary)';
});
// Log page load
console.log('🎬 Data-Driven Filmmaker\'s Playbook loaded successfully');
console.log('📊 Analyzing 7,070 films to help you make better movies');