-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
130 lines (111 loc) · 3.83 KB
/
Copy pathscript.js
File metadata and controls
130 lines (111 loc) · 3.83 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
// Add smooth scroll behavior
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Animate articles on scroll
const observerOptions = {
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate__fadeIn');
observer.unobserve(entry.target);
}
});
}, observerOptions);
document.querySelectorAll('.article-card').forEach(article => {
observer.observe(article);
});
// Add dynamic loading of more articles
function loadMoreArticles() {
const articlesList = document.querySelector('.articles-list');
// Simulate loading new articles
const newArticle = document.createElement('article');
newArticle.className = 'article-card animate__animated animate__fadeIn';
newArticle.innerHTML = `
<img src="https://picsum.photos/800/${Math.floor(Math.random() * 100) + 400}" alt="Article image">
<div class="article-content">
<h2>New Article Title</h2>
<p class="article-meta">By Author Name | ${new Date().toLocaleDateString()}</p>
<p class="article-excerpt">New article content goes here...</p>
<a href="#" class="read-more">Read More</a>
</div>
`;
articlesList.appendChild(newArticle);
}
// Add scroll-to-top button
const scrollButton = document.createElement('button');
scrollButton.innerHTML = '↑';
scrollButton.className = 'scroll-to-top';
document.body.appendChild(scrollButton);
scrollButton.addEventListener('click', () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
// Show/hide scroll button based on scroll position
window.addEventListener('scroll', () => {
if (window.pageYOffset > 300) {
scrollButton.style.display = 'block';
} else {
scrollButton.style.display = 'none';
}
});
// Add scroll effect for header
window.addEventListener('scroll', () => {
const header = document.querySelector('header');
if (window.scrollY > 50) {
header.classList.add('scrolled');
} else {
header.classList.remove('scrolled');
}
});
// Back to Top Button
document.addEventListener('DOMContentLoaded', function() {
const backToTopButton = document.getElementById('backToTop');
if (backToTopButton) {
window.addEventListener('scroll', () => {
if (window.pageYOffset > 300) {
backToTopButton.classList.add('visible');
} else {
backToTopButton.classList.remove('visible');
}
});
backToTopButton.addEventListener('click', () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
}
});
// Add this new function
document.addEventListener('DOMContentLoaded', () => {
const logos = document.querySelectorAll('.logo-text');
const symbols = ['$', '€', '£', '¥', '₿', '₹', '₽'];
logos.forEach(logo => {
const text = logo.dataset.value;
let iterations = 0;
const interval = setInterval(() => {
logo.innerText = logo.innerText.split('')
.map((letter, index) => {
if(index < iterations) {
return text[index];
}
return symbols[Math.floor(Math.random() * symbols.length)];
})
.join('');
if(iterations >= text.length) {
clearInterval(interval);
}
iterations += 1/4;
}, 45);
});
});