Skip to content

Commit a57bb4c

Browse files
committed
Changed to locomotive-AOS to prevent dependency conflicts
1 parent 1b2d139 commit a57bb4c

File tree

9 files changed

+130
-32
lines changed

9 files changed

+130
-32
lines changed

package-lock.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@testing-library/react": "^13.4.0",
99
"@testing-library/user-event": "^13.5.0",
1010
"emailjs-com": "^3.2.0",
11+
"locomotive-aos": "^1.0.7",
1112
"locomotive-scroll": "^4.1.4",
1213
"react": "^18.3.1",
1314
"react-dom": "^18.3.1",

src/SmoothScroll.jsx

+23-16
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ import React, { useEffect } from 'react';
3939
import { BrowserRouter, Link } from 'react-router-dom';
4040
import App from './App';
4141
import LocomotiveScroll from 'locomotive-scroll';
42-
import AOS from 'locomotive-aos';
43-
import 'aos/dist/aos.css'; // Import AOS styles
42+
import Aos from 'locomotive-aos';
43+
import './styles/Aos.css'; // Import AOS styles
4444
import 'locomotive-scroll/dist/locomotive-scroll.css';
45+
import getMode from './utils/getMode';
4546

4647
const SmoothScroll = () => {
4748
useEffect(() => {
@@ -52,9 +53,10 @@ const SmoothScroll = () => {
5253
smooth: true,
5354
});
5455

55-
AOS.init({
56+
Aos.init({
5657
duration: 1000,
5758
once: true,
59+
easing: "ease-in-out"
5860
});
5961

6062
const handleScroll = () => {
@@ -77,22 +79,27 @@ const SmoothScroll = () => {
7779
return (
7880
<BrowserRouter basename={process.env.PUBLIC_URL}>
7981
<div id="root">
80-
<header style={{ opacity: 0, transition: 'opacity 0.5s ease-in-out' }}>
81-
<nav>
82-
<ul>
83-
<li><Link to="/">Home</Link></li>
84-
<li><Link to="/syllabus">Syllabus</Link></li>
85-
<li><Link to="/staff">Staff</Link></li>
86-
<li><Link to="/inquiry">Inquiry</Link></li>
87-
</ul>
88-
</nav>
89-
</header>
90-
<main id="main-container" data-scroll-container>
91-
<App />
92-
</main>
82+
<div style={{
83+
backgroundColor: getMode() === "dark" ? "#18181B" : "#f3f3f3"
84+
}}>
85+
<header style={{ opacity: 0, transition: 'opacity 0.5s ease-in-out' }}>
86+
<nav>
87+
<ul>
88+
<li><Link to="/">Home</Link></li>
89+
<li><Link to="/syllabus">Syllabus</Link></li>
90+
<li><Link to="/staff">Staff</Link></li>
91+
<li><Link to="/inquiry">Inquiry</Link></li>
92+
</ul>
93+
</nav>
94+
</header>
95+
<main id="main-container" data-scroll-container>
96+
<App />
97+
</main>
98+
</div>
9399
</div>
94100
</BrowserRouter>
95101
);
96102
};
97103

104+
98105
export default SmoothScroll;

src/components/Header.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { Link } from 'react-router-dom';
33
import '../styles/App.css';
4+
import '../styles/ScrollBar.css'
45

56
const Header = () => (
67
<>

src/components/observer.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const observer = new IntersectionObserver((entries) => {
2+
entries.forEach((entry) => {
3+
console.log(entry)
4+
if(entry.isIntersecting){
5+
entry.target.classList.add('show');
6+
}
7+
else{
8+
entry.target.classList.remove('show');
9+
}
10+
});
11+
});
12+
13+
const hiddenElements = document.querySelectorAll('.hidden');
14+
hiddenElements.forEach((el) => observer.observe(el));

src/pages/Home.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import '../styles/App.css';
55
import { Toaster } from 'sonner';
66
import showNotif from '../components/ToastNotif';
77

8+
89
const Home = () => (
910
<div data-scroll-section id='main-container'>
1011

src/styles/Aos.css

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[data-aos] {
2+
opacity: 0;
3+
transition-property: opacity, transform;
4+
}
5+
6+
[data-aos].aos-animate {
7+
opacity: 1;
8+
}
9+
10+
[data-aos][data-aos-easing="ease-in-out"] {
11+
transition-timing-function: ease-in-out;
12+
}
13+
14+
[data-aos][data-aos-duration] {
15+
transition-duration: var(--aos-duration);
16+
}
17+
18+
[data-aos][data-aos-delay] {
19+
transition-delay: var(--aos-delay);
20+
}
21+
22+
/* Example of specific animation keyframes */
23+
@keyframes fade-up {
24+
from {
25+
transform: translate3d(0, 50%, 0);
26+
opacity: 0;
27+
}
28+
to {
29+
transform: translate3d(0, 0, 0);
30+
opacity: 1;
31+
}
32+
}
33+
34+
[data-aos="fade-up"].aos-animate {
35+
animation: fade-up var(--aos-duration) ease-in-out forwards;
36+
}
37+
38+
39+
[data-aos].aos-animate {
40+
opacity: 1;
41+
}
42+
43+
[data-aos="fade-up"] {
44+
transform: translate3d(0, 100px, 0);
45+
}
46+
47+
[data-aos="fade-up"].aos-animate {
48+
transform: translate3d(0, 0, 0);
49+
}

src/styles/App.css

+11-16
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ main {
3535
overflow: hidden; /* Prevent unwanted scrollbars */
3636
}
3737

38+
3839
.flex-container {
3940
display: flex;
4041
flex-direction: column;
@@ -131,23 +132,17 @@ main {
131132
}
132133
}
133134

134-
.scroll-watcher-light{
135-
background-color: linear-gradient(to right, #2ecfe1, #96c93d);
135+
.hidden{
136+
opacity: 0;
137+
transition: all 1s;
136138
}
137139

138-
.scroll-watcher-dark{
139-
background-color: linear-gradient(to right #ff7700, #9c00c3);
140+
@media(prefers-reduced-motion) {
141+
.hidden{
142+
transition: none;
143+
}
140144
}
141145

142-
143-
.scroll-watcher-light, .scroll-watcher-dark {
144-
height: 5px;
145-
position: fixed;
146-
top: 0;
147-
width: 100%;
148-
z-index: 1000;
149-
animation: linear;
150-
animation-timeline: scroll(y);
151-
scale: 0, 1;
152-
transform-origin: left;
153-
}
146+
.show{
147+
opacity: 1;
148+
}

src/styles/Scrollbar.css

+24
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
14

5+
6+
.scroll-watcher-light{
7+
background-color: linear-gradient(to right, #2ecfe1, #96c93d);
8+
}
9+
10+
.scroll-watcher-dark{
11+
background-color: linear-gradient(to right #ff7700, #9c00c3);
12+
}
13+
14+
15+
.scroll-watcher-light, .scroll-watcher-dark {
16+
height: 5px;
17+
position: fixed;
18+
top: 0;
19+
width: 100%;
20+
z-index: 1000;
21+
animation: linear;
22+
animation-timeline: scroll(y);
23+
scale: 0, 1;
24+
transform-origin: left;
25+
}

0 commit comments

Comments
 (0)