Animate HTML Elements on Scrolling without Coding
Animation is any visual effects applied on a web page to make it look interactive and interesting. Mostly, animating the elements on a web page can be achieved by using CSS and JavaScript. However, some people find it difficult because they do not know what CSS properties to use or what JavaScript codes to be applied. Moreover, when it comes to animation on scrolling, it is when user sees HTML elements when they scroll the page up and down, the work turns a little bit tricky. So, in this post, I will show you how to animate html elements on scrolling without coding CSS and JS by yourself. What? Without coding? Well, someone else had done it for us so all we need to do is to implement it.
Animate on Scrolling (AOS) Library
Animate on Scrolling, AOS, is a CSS-JS Library created by Michalsnik to help us add animation on any HTML elements on scrolling. It can be used for free and is available on Github.
Like using Bootstrap or jQuery, all we need to do is to add a <link> and <script> tags that refer to the CSS and JS files (there are only two files, amazing!) of the library.
Installing AOS
If you have control on your website, you can download the files from AOS Github and put the into your assets folder. Then, you add the following tags in the header of the page.
<link rel="stylesheet" type="text/css" href="path/to/your/assets/folder/aos.css"/>
<script type="text/javascript" src="path/to/your/assets/folder/aos.js"></script>
<script>AOS.init();</script>
Othewise, if you are using Blogger like me, you can put the following tags in the header of the template.
<link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
<script src="https://unpkg.com/aos@next/dist/aos.js"></script>
<script>AOS.init();</script>
Implementing AOS
Now, after installing AOS, we need to add attributes data-aos to the elements that we want to animate on scroll. There are plenty of animations that we can implement like fade, flip, and so on. Below are some examples of the attribute values.
Fade animations:
I use data-aos-duration="1000" data-aos="fade-up"
- fade
- fade-up
- fade-down
- fade-left
- fade-right
- fade-up-right
- fade-up-left
- fade-down-right
- fade-down-left
Flip animations:
- flip-up
- flip-down
- flip-left
- flip-right
Slide animations:
I use data-aos-duration="1000" data-aos="slide-up"
- slide-up
- slide-down
- slide-left
- slide-right
Zoom animations:
I use data-aos-duration="1000" data-aos="flip-up"- zoom-in
- zoom-in-up
- zoom-in-down
- zoom-in-left
- zoom-in-right
- zoom-out
- zoom-out-up
- zoom-out-down
- zoom-out-left
- zoom-out-right
Anchor placements:
- top-bottom
- top-center
- top-top
- center-bottom
- center-center
- center-top
- bottom-bottom
- bottom-center
- bottom-top
Easing functions:
I use data-aos-duration="1000" data-aos="fade-down"
- linear
- ease
- ease-in
- ease-out
- ease-in-out
- ease-in-back
- ease-out-back
- ease-in-out-back
- ease-in-sine
- ease-out-sine
- ease-in-out-sine
- ease-in-quad
- ease-out-quad
- ease-in-out-quad
- ease-in-cubic
- ease-out-cubic
- ease-in-out-cubic
- ease-in-quart
- ease-out-quart
- ease-in-out-quart
Well, they are amazing, aren't they? Happy animate. For more detail, check on Offical AOS page.
Please, only relevant comments are accepted. Comments that are irrelevant and/or containing active links will be deleted. Thank you.
Post a Comment for "Animate HTML Elements on Scrolling without Coding"