Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using aos in Astro #836

Open
ayemin-tun opened this issue Oct 18, 2023 · 3 comments
Open

Using aos in Astro #836

ayemin-tun opened this issue Oct 18, 2023 · 3 comments

Comments

@ayemin-tun
Copy link

This is:

  • Question

Detailed Description

"I use AOS in my Astro project, and it works fine, but it has an issue. For example, when I use AOS on the home page, the animations work correctly when the page is initially loaded, but they are too fast when navigating between pages. If I go to the about page and then return to the home page, the animations are too fast to see. Why is this happening? Please help or provide information to solve this issue. Do I need to install anything additional for AOS in my project?"

The way I install aos on my astro project

  • in my src/js directory I add aos.js and it contain this code

import AOS from "aos";

export function aosInit() {
    AOS.init({ duration: 1000, easing: "ease-out-cubic", once: false, offset: 50 });
}
  • in main layout I add this
<script>
    import { aosInit } from "@/js/aos";
    aosInit();
  </script>
@Boston343
Copy link

I'm not exactly sure why it happens (seems a CSS problem), but for me it only happens when you use view transitions. I'm currently working on my own animation setup using animejs with some logic taken from AOS for intersections. I plan to share it once done - it works with view transitions.

@joshuaiz
Copy link

You might need to import the css as well - I have it working in Astro with this:

<script>
    import AOS from 'aos'
    import 'aos/dist/aos.css'

    AOS.init()
</script>

@RayyanNafees
Copy link

RayyanNafees commented Jul 15, 2024

u have to import css at the top in

---
---

section & in script tag import the js only

---
import 'aos/dist/aos.css'
---
<script>
    import AOS from 'aos'
    AOS.init()
</script>

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants