“How to customize animations on AOS Library?”
AOS Library (by michalsnik) is a great way to trigger animation while scroll for your website design. Here’s how to customize animations using AOS library.
Add CSS to your website header
<link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
Add JS at the end of body tag
<script src="https://unpkg.com/aos@next/dist/aos.js"></script>
<script type="text/javascript">
AOS.init({
});
</script>
HTML
<div class="box" data-aos="my-animation-1">1</div> <div class="box" data-aos="my-animation-2">2</div> <div class="box" data-aos="my-animation-3">3</div> <div class="box" data-aos="my-animation-1">4</div> <div class="box" data-aos="my-animation-2">5</div> <div class="box" data-aos="my-animation-3">6</div> <div class="box" data-aos="my-animation-1">7</div> <div class="box" data-aos="my-animation-2">8</div> <div class="box" data-aos="my-animation-3">9</div>
CSS
/* Default Style of Boxes */
.box {
width: 250px;
height: 250px;
margin: 2rem auto;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
font-family:sans-serif;
font-size: 5rem;
color: #FFF;
}
/* Before of Animation 1 */
[data-aos="my-animation-1"] {
transform: rotate(0deg);
background: black;
opacity: 0;
}
/* After of Animation 1 */
[data-aos="my-animation-1"].aos-animate {
transform: rotate(360deg);
opacity: 1;
}
/* Before of Animation 2 */
[data-aos="my-animation-2"] {
background: black;
transition-property: background;
}
/* After of Animation 2 */
[data-aos="my-animation-2"].aos-animate {
background: cyan;
}
/* Before of Animation 3 */
[data-aos="my-animation-3"] {
transform: translateX(-100%);
opacity: 0;
}
/* After of Animation 3 */
[data-aos="my-animation-3"].aos-animate {
transform: translateX(0%);
background: purple;
opacity: 1;
}
DEMO: How It Looks
1
2
3
4
5
6
7
8
9