-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
93 lines (63 loc) · 2.76 KB
/
script.js
File metadata and controls
93 lines (63 loc) · 2.76 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
window.addEventListener('scroll', () => {
const scrollY = window.scrollY;
const cloudTop = document.querySelector('.cloud-top');
const cloudBottom = document.querySelector('.cloud-bottom');
cloudTop.style.transform = `translateX(${scrollY * 0.5}px)`;
cloudBottom.style.transform = `translateX(${-scrollY * 0.5}px)`;
});
let lastScrollPosition = 0;
const sliderText = document.querySelector(".slider-text");
window.addEventListener("scroll", () => {
const scrollPosition = window.scrollY;
// Calculate the difference in scroll position
const scrollDelta = scrollPosition - lastScrollPosition;
// Update the text's position based on scroll direction
const currentLeft = parseFloat(getComputedStyle(sliderText).left) || 0;
const newLeft = currentLeft + scrollDelta * 1.5; // Increased multiplier for faster movement
// Apply the new position
sliderText.style.left = `${newLeft}px`;
// Update the last scroll position
lastScrollPosition = scrollPosition;
});
const handleScrollAnimations1 = () => {
const elements = document.querySelectorAll('.content p, .content h2, .masonry-item');
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
entry.target.style.transition = 'opacity 0.8s ease-out, transform 0.8s ease-out';
} else {
entry.target.style.opacity = '0';
entry.target.style.transform = 'translateY(20px)';
entry.target.style.transition = 'opacity 0.8s ease-out, transform 0.8s ease-out';
}
});
}, {
threshold: 0.5,
});
elements.forEach((el) => observer.observe(el));
};
document.addEventListener('DOMContentLoaded', handleScrollAnimations1);
const handleScrollAnimations = () => {
const images = document.querySelectorAll('.image-grid img');
const tableRows = document.querySelectorAll('table tbody tr');
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'scale(1)';
entry.target.style.transition = 'opacity 0.8s ease-out, transform 0.8s ease-out';
} else {
entry.target.style.opacity = '0';
entry.target.style.transform = 'scale(0.9)';
entry.target.style.transition = 'opacity 0.8s ease-out, transform 0.8s ease-out';
}
});
}, {
threshold: 0.5,
});
images.forEach((img) => observer.observe(img));
tableRows.forEach((row) => observer.observe(row));
};
document.addEventListener('DOMContentLoaded', handleScrollAnimations);