Skip to content

Instantly share code, notes, and snippets.

@AllanJeremy
Created July 25, 2017 22:06
Show Gist options
  • Save AllanJeremy/6c673fbd4229eadf798ed947d65983c5 to your computer and use it in GitHub Desktop.
Save AllanJeremy/6c673fbd4229eadf798ed947d65983c5 to your computer and use it in GitHub Desktop.
Animatable fontawesome icons
//need to figure way of fixing timeout in loop
function AnimateIcon(iconList,elementId,timeInSeconds)
{
timeInSeconds*=1000;//Convert the timeIn seconds to milliseconds
var element = document.getElementById(elementId);//Get the element
var totalAnimationTime = 0;
var i = 0;
element.innerHTML= iconList[i];
//Loop through all icons in the icon list
setTimeout(function(){
totalAnimationTime += ((i+1)*timeInSeconds);
element.innerHTML = iconList[i];
console.log(i);
i++;
},((i+1)*timeInSeconds));
}
//Testing it out
var batteryCharge = ["&#xf244","&#xf243","&#xf242","&#xf241","&#xf240"];
AnimateIcon(batteryCharge,"battery",1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment