FULL STACK   ·   UI   ·   UX   ·   GRAPHICS   ·   DEVELOPER   ·   INSTRUCTOR

Adam Khoury

Donate funds to show love and support

Click the button below to donate funds securely online. You can use your PayPal account or a credit card.

Your donations help free up my time to produce more content and assist in covering server costs. It's also a great way to say thanks for the content!

Application Configuration

Adam will be adding options here soon.

Transform Rotate Image Spin Smooth Animation Tutorial

Published :
Author :
Adam Khoury
Learn to program any CSS property animations you want using JavaScript and the CSS3 transform property, and just a few lines of code. JavaScript offers your animations more flexibility regarding user interactivity with your animations. CSS alone cannot offer you all of the DOM event handlers that are useful for programming advanced interactivity with the animated elements. <!DOCTYPE html> <html> <head> <script> var looper; var degrees = 0; function rotateAnimation(el,speed){ var elem = document.getElementById(el); if(navigator.userAgent.match("Chrome")){ elem.style.WebkitTransform = "rotate("+degrees+"deg)"; } else if(navigator.userAgent.match("Firefox")){ elem.style.MozTransform = "rotate("+degrees+"deg)"; } else if(navigator.userAgent.match("MSIE")){ elem.style.msTransform = "rotate("+degrees+"deg)"; } else if(navigator.userAgent.match("Opera")){ elem.style.OTransform = "rotate("+degrees+"deg)"; } else { elem.style.transform = "rotate("+degrees+"deg)"; } looper = setTimeout('rotateAnimation(\''+el+'\','+speed+')',speed); degrees++; if(degrees > 359){ degrees = 1; } document.getElementById("status").innerHTML = "rotate("+degrees+"deg)"; } </script> </head> <body> <img id="img1" src="cog1.png" alt="cog1"> <script>rotateAnimation("img1",30);</script> <h2 style="width:200px;" id="status"></h2> </body> </html>