Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
110 lines (96 loc) · 3.65 KB
/
Copy pathscript.js
File metadata and controls
110 lines (96 loc) · 3.65 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
// Smooth scroll animation for sections
document.addEventListener('DOMContentLoaded', function() {
// Observe elements for fade-in animation on scroll
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Apply observer to all PDF cards and sections
const sections = document.querySelectorAll('.math-section');
const cards = document.querySelectorAll('.pdf-card');
sections.forEach(section => {
section.style.opacity = '0';
section.style.transform = 'translateY(20px)';
section.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(section);
});
cards.forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(15px)';
card.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
observer.observe(card);
});
// Add click animation to PDF links
const pdfLinks = document.querySelectorAll('.pdf-link');
pdfLinks.forEach(link => {
link.addEventListener('click', function(e) {
// Create ripple effect
const ripple = document.createElement('span');
ripple.style.position = 'absolute';
ripple.style.borderRadius = '50%';
ripple.style.background = 'rgba(255, 255, 255, 0.6)';
ripple.style.width = '20px';
ripple.style.height = '20px';
ripple.style.pointerEvents = 'none';
ripple.style.animation = 'ripple-animation 0.6s ease-out';
const rect = this.getBoundingClientRect();
const size = Math.max(rect.width, rect.height);
const x = e.clientX - rect.left - size / 2;
const y = e.clientY - rect.top - size / 2;
ripple.style.left = x + 'px';
ripple.style.top = y + 'px';
ripple.style.width = size + 'px';
ripple.style.height = size + 'px';
this.style.position = 'relative';
this.style.overflow = 'hidden';
this.appendChild(ripple);
setTimeout(() => {
ripple.remove();
}, 600);
});
});
// Add hover scale effect to PDF cards
const cards_list = document.querySelectorAll('.pdf-card');
cards_list.forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-4px) scale(1.02)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) scale(1)';
});
});
// Smooth scroll to top button (optional)
window.addEventListener('scroll', function() {
const scrolled = window.scrollY;
const header = document.querySelector('header');
if (scrolled > 100) {
header.style.boxShadow = '0 4px 20px rgba(211, 180, 140, 0.3)';
} else {
header.style.boxShadow = '0 4px 12px rgba(211, 180, 140, 0.25)';
}
});
});
// Add ripple animation to CSS dynamically
const style = document.createElement('style');
style.textContent = `
@keyframes ripple-animation {
from {
transform: scale(1);
opacity: 1;
}
to {
transform: scale(4);
opacity: 0;
}
}
`;
document.head.appendChild(style);