Animate a div on mouse scroll using AOS
AOS is a small library to animate elements on your page as you scroll.
AOS allows you to animate elements as you scroll down, and up. If you scroll back to top, elements will animate to it’s previous state and are ready to animate again if you scroll down.
Installation: Installing AOS is very simple:
- Add the below tag in the head tag of the webpage.
<link rel=”stylesheet” href=”https://unpkg.com/aos@next/dist/aos.css” />
- Add script right before closing </head> tag, and initialize AOS:
That’s it, now you have successfully installed aos in your webapp.
Set animation using data-aos attribute :
Example: Below is an example to demonstrate animation effect.