Skip to content

Instantly share code, notes, and snippets.

@crongro
Created December 27, 2013 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crongro/8144134 to your computer and use it in GitHub Desktop.
Save crongro/8144134 to your computer and use it in GitHub Desktop.
A Pen by younjisu.
<div id="ani"></div>
var easeInAni = function(){
var incrementer = 0;
function animate() {
incrementer++;
var step = Math.pow(1.05,incrementer);
var ele = $('#ani');
if(ele.css('left').replace(/px/,"") > 1000) return;
var num = 10+step;
ele.css('left', "+="+num);
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
});
var circleAni = function() {
var angle =0;
var step = 0.05;
function animateOscillation() {
angle+=step;
var xPos = 200 + 100*Math.cos(angle);
var yPos = 200 + 100*Math.sin(angle);
$('#ani').css({'left' : xPos, 'top' : yPos});
requestAnimationFrame(animateOscillation);
}
requestAnimationFrame(animateOscillation);
}
circleAni()
div#ani {
background-color : red;
width : 30px;
height : 30px;
position : absolute;
top : 200px;
left : 300px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment