Created
December 27, 2013 08:26
-
-
Save crongro/8144134 to your computer and use it in GitHub Desktop.
A Pen by younjisu.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="ani"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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