Skip to content

Commit 11b7bf2

Browse files
committed
JFRA-00: Implement GSAP scrollTo on main layout.
1 parent e79ceaf commit 11b7bf2

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

src/layouts/Layout.astro

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,45 @@ const locale = Astro.currentLocale as Lang;
8686
<ScrollUp />
8787
</body>
8888
</html>
89+
90+
<script>
91+
import gsap from 'gsap';
92+
import { ScrollTrigger } from 'gsap/ScrollTrigger';
93+
94+
gsap.registerPlugin(ScrollTrigger);
95+
96+
function initScrollAnimations() {
97+
ScrollTrigger.getAll().forEach(trigger => trigger.kill());
98+
99+
gsap.utils.toArray('.section').forEach((section: any, index: number) => {
100+
gsap.from(section, {
101+
opacity: 0,
102+
y: 150,
103+
duration: 1,
104+
ease: 'power2.out',
105+
scrollTrigger: {
106+
trigger: section,
107+
start: 'top 75%',
108+
end: 'top 25%',
109+
toggleActions: 'play none none none',
110+
},
111+
});
112+
});
113+
114+
gsap.utils.toArray('.section__title').forEach((title: any) => {
115+
gsap.from(title, {
116+
opacity: 0,
117+
scale: 0.5,
118+
duration: 0.8,
119+
ease: 'back.out(1.7)',
120+
scrollTrigger: {
121+
trigger: title,
122+
start: 'top 80%',
123+
toggleActions: 'play none none none',
124+
},
125+
});
126+
});
127+
}
128+
129+
document.addEventListener('astro:page-load', initScrollAnimations);
130+
</script>

src/sections/Home.astro

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ const t = useTranslations(Astro.currentLocale as Lang);
141141
cursor: pointer;
142142
}
143143

144+
@media screen and (max-width: 567px) {
145+
#contact-button {
146+
display: flex;
147+
justify-content: center;
148+
width: 100%;
149+
}
150+
}
151+
144152
@keyframes float {
145153
0%,
146154
100% {

src/styles/base.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ body {
7474
font-size: var(--normal-font-size);
7575
background-color: var(--body-color);
7676
color: var(--text-color);
77+
overflow-x: hidden;
7778
}
7879

7980
h1,

0 commit comments

Comments
 (0)