-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript-scroll-additions.js
More file actions
87 lines (72 loc) · 3.03 KB
/
script-scroll-additions.js
File metadata and controls
87 lines (72 loc) · 3.03 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
// ============================================
// تأثيرات السكرول الاحترافية - مدمجة في الملف الرئيسي
// ============================================
// مؤشر تقدم السكرول
function initScrollProgress() {
const progressBar = document.createElement('div');
progressBar.className = 'scroll-progress';
document.body.appendChild(progressBar);
window.addEventListener('scroll', () => {
const windowHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
const scrolled = (window.scrollY / windowHeight) * 100;
progressBar.style.width = scrolled + '%';
});
}
// تأثيرات الظهور عند السكرول
function initScrollEffects() {
const observerOptions = {
threshold: 0.15,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible', 'revealed');
}
});
}, observerOptions);
const addScrollClasses = () => {
document.querySelectorAll('.calculator-card').forEach((card, index) => {
card.classList.add('scroll-reveal');
card.style.transitionDelay = `${index * 0.1}s`;
observer.observe(card);
});
document.querySelectorAll('.feature-card').forEach((card, index) => {
const direction = index % 2 === 0 ? 'scroll-slide-left' : 'scroll-slide-right';
card.classList.add(direction);
card.style.transitionDelay = `${index * 0.1}s`;
observer.observe(card);
});
document.querySelectorAll('.stat-card, .analytics-card').forEach((card, index) => {
card.classList.add('scroll-scale-up');
card.style.transitionDelay = `${index * 0.1}s`;
observer.observe(card);
});
};
setTimeout(addScrollClasses, 100);
document.querySelectorAll('.tab-btn').forEach(btn => {
btn.addEventListener('click', () => {
setTimeout(addScrollClasses, 300);
});
});
}
// تأثير Parallax
function initParallax() {
const heroSection = document.querySelector('.hero-section');
if (!heroSection) return;
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const parallaxSpeed = 0.5;
if (heroSection && scrolled < window.innerHeight) {
heroSection.style.transform = `translateY(${scrolled * parallaxSpeed}px)`;
}
});
const particlesContainer = document.getElementById('particles-js');
if (particlesContainer) {
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
particlesContainer.style.transform = `translateY(${scrolled * 0.3}px)`;
particlesContainer.style.opacity = 1 - (scrolled / 1000);
});
}
}