Day # 16: Earrings animation



A few days ago I ran into a post on Instagram that featured a catalog of earrings. It was shown like an animation: some of the earrings rotated while others increased their sizes.


I figured it was a good way to practice animations by using Javascript, so I decided to choose a group of icons from Font Awesome and animate them. To achieve that I had to learn how to use the Javascript method setInterval, which allows you to run a function given a certain interval.


To increase the sizes of some icons, I set the transform property to the scale values:

function animateEarrings2() {

    fan.style.transform = "scale(1)";

}


And to rotate other icons, I set the transform property to the rotate values:


function animateEarrings3() {

    bone.style.transform = "rotate(35deg)";

}


Finally, I invoked those functions within the setInterval method:

setInterval(animateEarrings1, 1000);

In the end I realized that this is a good exercise for anyone who wishes to practice animations through Javascript. During this project, I was able to learn the setInterval method, and I am sure that if you also decided to do it, you can learn lots of other concepts while having fun at it!


Comments

Popular posts from this blog

Day # 35: Flip Book

Day # 1: Homepage w/Introduction

Day # 8: Inspiration