Introduction
There are many libraries for animation on scroll. In this tutorial we will see the animation on scroll using AOS library. Animation on scroll using AOS Animate On Scroll Library. AOS is also called as Animation On scroll. AOS provides different kind of animations on scroll.
Steps to add animation on scroll
Step 1: Add AOS library
You can add the AOS library in your project by two ways
- Use direct links
CSS : <link href=”https://unpkg.com/[email protected]/dist/aos.css” rel=”stylesheet”>
JS: <script src=”https://unpkg.com/[email protected]/dist/aos.js”></script> - Download the library and include the files
To download the AOS library CLICK HERE
Once you download the zip add the aos.css and aos.js file from dist folder to your project. Animation on scroll using AOS Animate On Scroll Library
Step 2: Initialize AOS
To initialize the AOS add below script before the end of body tag
<script>
AOS.init();
</script>
Step 3: Add the animation classes
AOS library provides number of classes for different types of animation
- FADE
- data-aos=”fade-up”
- data-aos=”fade-down”
- data-aos=”fade-right”
- data-aos=”fade-left”
- data-aos=”fade-up-right”
- data-aos=”fade-up-left”
- data-aos=”fade-down-right”
- data-aos=”fade-down-left”
- FlIP
- data-aos=”flip-left”
- data-aos=”flip-right”
- data-aos=”flip-up”
- data-aos=”flip-down”
- ZOOM
- data-aos=”zoom-in”
- data-aos=”zoom-in-up”
- data-aos=”zoom-in-down”
- data-aos=”zoom-in-lef”
- data-aos=”zoom-in-right”
- data-aos=”zoom-out”
- data-aos=”zoom-out-up”
- data-aos=”zoom-out-down”
- data-aos=”zoom-out-left”
- data-aos=”zoom-out-right”
- DIFFERENT SETTINGS EXAMPLES
- data-aos-duration=”3000″
it will set the speed of flip, zoom, fade - data-aos-easing=”linear”
This attribute is used to control the time function of the animating element. It has three values linear,ease-in-out and ease-out-quart
- data-aos-duration=”3000″
- ANCHOR PLACEMENT
data-aos-anchor-placement — By default, the animations on an element are applied as soon as its top part reaches the bottom part of the window. This behavior can be changed using the data-aos-anchor-placement attribute- data-aos-anchor-placement=”top-bottom”
- data-aos-anchor-placement=”center-bottom”
- data-aos-anchor-placement=”bottom-bottom”
- data-aos-anchor-placement=”top-center”
- data-aos-anchor-placement=”top-center”
- Animate for first scroll only
To animate only for first scroll add attribute data-aos-once=”ture”
To see the demo CLICK HERE