Skip to content

Commit c75d324

Browse files
committed
new version
1 parent 7a76620 commit c75d324

File tree

5 files changed

+52
-13
lines changed

5 files changed

+52
-13
lines changed

src/App.jsx

+34-8
Original file line numberDiff line numberDiff line change
@@ -103,36 +103,43 @@ const App = () => {
103103
export default App;
104104
105105
*/
106-
107106
import React, { useEffect, useState } from 'react';
108107
import { BrowserRouter } from 'react-router-dom';
109108
import Routing from './Routing';
110109
import LocomotiveScroll from 'locomotive-scroll';
111110
import 'locomotive-scroll/dist/locomotive-scroll.css';
112-
import './styles/Aos.css';
113-
import './styles/Header.css';
111+
import AOS from 'aos';
112+
import 'aos/dist/aos.css';
114113

115114
import Header from './components/Header';
115+
import Footer from './components/Footer';
116116
import getMode from './utils/getMode';
117+
import './styles/Header.css';
117118

118119
const App = () => {
119120
const [showProgressBar, setShowProgressBar] = useState(false);
120121

121122
useEffect(() => {
122123
const scrollEl = document.querySelector('#main-container');
123124
const headerEl = document.querySelector('header');
125+
const footerEl = document.querySelector('footer');
124126

125127
const scroll = new LocomotiveScroll({
126128
el: scrollEl,
127129
smooth: true,
128130
});
129131

132+
AOS.init({
133+
duration: 1000,
134+
once: true,
135+
easing: 'ease-in-out',
136+
});
137+
130138
const observer = new IntersectionObserver((entries) => {
131139
entries.forEach((entry) => {
132140
if (entry.isIntersecting) {
133141
entry.target.classList.add('aos-animate');
134-
} else {
135-
entry.target.classList.remove('aos-animate');
142+
observer.unobserve(entry.target);
136143
}
137144
});
138145
});
@@ -163,10 +170,30 @@ const App = () => {
163170
if (headerEl) {
164171
if (scrollPosition > windowHeight / 2.5) {
165172
headerEl.style.opacity = '1';
173+
headerEl.classList.add('visible');
166174
} else {
167175
headerEl.style.opacity = '0';
176+
headerEl.classList.remove('visible');
177+
}
178+
}
179+
180+
if (footerEl) {
181+
if (scrollPosition + windowHeight >= totalHeight) {
182+
footerEl.style.opacity = '1';
183+
footerEl.classList.add('visible');
184+
} else {
185+
footerEl.style.opacity = '0';
186+
footerEl.classList.remove('visible');
168187
}
169188
}
189+
190+
// Reset animations when reaching the top
191+
if (scrollPosition === 0) {
192+
document.querySelectorAll('[data-aos]').forEach((aosElem) => {
193+
aosElem.classList.remove('aos-animate');
194+
observer.observe(aosElem);
195+
});
196+
}
170197
};
171198

172199
scroll.on('scroll', handleScroll);
@@ -182,8 +209,7 @@ const App = () => {
182209
<BrowserRouter basename={process.env.PUBLIC_URL}>
183210
<>
184211
{showProgressBar && (
185-
<div
186-
id="progress-bar"
212+
<div id="progress-bar"
187213
className={(getMode() === "dark") ? "scroll-watcher-dark" : "scroll-watcher-light"}
188214
style={{ width: '0%' }}
189215
></div>
@@ -193,11 +219,11 @@ const App = () => {
193219
<main id="main-container" data-scroll-container>
194220
<Routing />
195221
</main>
222+
<Footer />
196223
</div>
197224
</>
198225
</BrowserRouter>
199226
);
200227
};
201228

202229
export default App;
203-

src/Routing.jsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ import Home from './pages/Home';
4242
import Syllabus from './pages/Syllabus';
4343
import Staff from './pages/Staff';
4444
import Inquiry from './pages/Inquiry';
45-
import AOS from 'locomotive-aos';
45+
import 'aos/dist/aos.css';
46+
import Aos from 'aos';
4647
import Popup from './components/Popup';
4748

4849
const Routing = () => {
4950
useEffect(() => {
50-
AOS.init({
51+
Aos.init({
5152
easing: 'ease-in-out',
52-
duration: 1300,
53+
duration: 1000,
5354
once: true,
5455
});
5556
}, []);
@@ -69,3 +70,4 @@ const Routing = () => {
6970
};
7071

7172
export default Routing;
73+

src/components/Footer.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const Footer = () => {
44
const currentYear = new Date().getFullYear();
55

66
return (
7-
<footer className="bg-gray-800 text-white text-center p-3 mt-8 text-sm"
7+
<footer className="bg-gray-800 text-white text-center p-3 mt-8 text-sm hidden"
88
style={{ opacity: 0, transition: 'opacity 0.5s ease-in-out' }}>
99
<p>&copy; {currentYear} LuminAI Innovate Scholars. All rights reserved.</p>
1010
</footer>

src/components/Header.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import getMode from '../utils/getMode';
66

77
const Header = () => (
88
<div>
9-
<header className={"bg-blue-600 text-white p-4" + (getMode() === "dark") ? "header-dark" : "header-light"}
9+
<header className={"bg-blue-600 text-white p-4 hidden" + (getMode() === "dark") ? "header-dark" : "header-light"}
1010
style={{ opacity: 0, transition: 'opacity 0.5s ease-in-out' }}>
1111
<div className="container mx-auto flex justify-between items-center">
1212
<h1 className="text-2xl">LuminAI Innovate Scholars</h1>

src/styles/App.css

+11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ main {
4141
}
4242

4343

44+
.hidden {
45+
visibility: hidden;
46+
pointer-events: none;
47+
}
48+
49+
.visible {
50+
visibility: visible;
51+
pointer-events: auto;
52+
}
53+
54+
4455
.flex-container {
4556
display: flex;
4657
flex-direction: column;

0 commit comments

Comments
 (0)