Skip to content

Commit 25ca320

Browse files
refactor(aos.js, vue-smooth-scroll.js, IndexPage.vue): Enhance AOS initialization and adjust delays
Enhance AOS (Animate On Scroll) initialization with client-side checks, streamline smooth scroll integration, and adjust AOS delays for better animation timing. Changes: - Add client-side checks in aos.js boot file for SSR compatibility - Add AOS configuration with proper settings - Streamline vue-smooth-scroll.js integration and add documentation - Simplify onScrollToTop in MainLayout.vue to use scroll position 0 - Adjust AOS delays in IndexPage.vue for staggered animations This improves animation timing and ensures AOS works correctly in SSR environments.
1 parent dca89fd commit 25ca320

File tree

4 files changed

+43
-15
lines changed

4 files changed

+43
-15
lines changed

src/boot/aos.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
import { boot } from 'quasar/wrappers';
22
import AOS from 'aos';
3-
import 'aos/dist/aos.css'; // You can also use <link> for styles
4-
// ..
5-
export default boot(({ app }) => {
6-
AOS.init();
3+
import 'aos/dist/aos.css';
4+
5+
export default boot(() => {
6+
// Only initialize AOS on client-side
7+
if (typeof window !== 'undefined') {
8+
// Initialize AOS with proper configuration
9+
AOS.init({
10+
duration: 800,
11+
easing: 'ease-in-out',
12+
once: false, // Allow animations to trigger again when scrolling back up
13+
mirror: false, // Don't animate elements when scrolling past them
14+
offset: 100, // Offset (in px) from the original trigger point
15+
delay: 0, // Delay (in ms) before animation starts
16+
anchorPlacement: 'top-bottom', // Defines which position of the element should trigger animation
17+
});
18+
}
719
});

src/boot/vue-smooth-scroll.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1+
import { boot } from 'quasar/wrappers';
12
import VueSmoothScroll from 'vue3-smooth-scroll';
2-
export default ({ app }) => {
3+
4+
export default boot(({ app }) => {
5+
// Install the vue3-smooth-scroll plugin
6+
// This provides:
7+
// 1. $smoothScroll on app.config.globalProperties (for Options API: this.$smoothScroll)
8+
// 2. v-smooth-scroll directive for template usage
9+
// 3. 'smoothScroll' via app.provide() (accessible via inject('smoothScroll') in Composition API)
310
app.use(VueSmoothScroll);
4-
};
11+
12+
// The plugin already provides 'smoothScroll' via inject(), so we don't need to provide it ourselves
13+
// Components can use: const smoothScroll = inject('smoothScroll')
14+
});

src/layouts/MainLayout.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,16 @@ export default {
178178
}
179179
180180
function onScrollToTop () {
181-
smoothScroll({
182-
scrollTo: document.getElementById('top'),
183-
updateHistory: false,
184-
});
181+
if (smoothScroll) {
182+
// Use smoothScroll to scroll to top (position 0)
183+
smoothScroll({
184+
scrollTo: 0,
185+
updateHistory: false,
186+
});
187+
} else {
188+
// Fallback to native smooth scroll
189+
window.scrollTo({ top: 0, behavior: 'smooth' });
190+
}
185191
}
186192
187193
function onGoToPanel (card) {

src/pages/IndexPage.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ generic-panel(
4747
div.row.items-center.justify-center
4848
div.col-xs-12.text-center
4949
div.row.justify-center.items-center
50-
div(data-aos="fade-up").col-xs-12.col-md-3.q-pa-sm
50+
div(data-aos="fade-up" data-aos-delay="0").col-xs-12.col-md-3.q-pa-sm
5151
a(href="https://stripe.com?ref=https://ossph.org" target="_blank")
5252
q-img(
5353
src="../assets/images/stripe-logo.png"
@@ -56,7 +56,7 @@ generic-panel(
5656
alt="Stripe Logo"
5757
)
5858
q-tooltip Stripe
59-
div(data-aos="fade-up").col-xs-12.col-md-3.q-pa-sm
59+
div(data-aos="fade-up" data-aos-delay="100").col-xs-12.col-md-3.q-pa-sm
6060
a(href="https://www.microsoft.com/en-us?ref=https://ossph.org" target="_blank")
6161
q-img(
6262
src="../assets/images/microsoft-logo.png"
@@ -65,7 +65,7 @@ generic-panel(
6565
alt="Microsoft Logo"
6666
)
6767
q-tooltip Microsoft
68-
div(data-aos="fade-up").col-xs-12.col-md-3.q-pa-sm
68+
div(data-aos="fade-up" data-aos-delay="200").col-xs-12.col-md-3.q-pa-sm
6969
a(href="https://www.edukasyon.ph?ref=https://ossph.org" target="_blank")
7070
q-img(
7171
src="../assets/images/edukasyon.jpg"
@@ -74,7 +74,7 @@ generic-panel(
7474
alt="Edukasyon.ph Logo"
7575
)
7676
q-tooltip Edukasyon.ph
77-
div(data-aos="fade-up").col-xs-12.col-md-3.q-pa-sm
77+
div(data-aos="fade-up" data-aos-delay="300").col-xs-12.col-md-3.q-pa-sm
7878
a(href="https://www.facebook.com/AWS.SiklabPH/?ref=https://ossph.org" target="_blank")
7979
q-img(
8080
src="../assets/images/aws-siklab-logo.png"
@@ -83,7 +83,7 @@ generic-panel(
8383
alt="AWS Siklab Logo"
8484
)
8585
q-tooltip AWS Siklab
86-
div(data-aos="fade-up").col-xs-12.col-md-3.q-pa-sm
86+
div(data-aos="fade-up" data-aos-delay="400").col-xs-12.col-md-3.q-pa-sm
8787
a(href="https://web3philippines.org/?ref=https://ossph.org" target="_blank")
8888
q-img(
8989
src="../assets/images/web3phl-logo.png"

0 commit comments

Comments
 (0)