Created
December 4, 2014 20:05
-
-
Save anonymous/4420502f11ad3d3fb9c5 to your computer and use it in GitHub Desktop.
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
/** | |
* Generate keyframe for CSS3 animation | |
* ios bounce icon effect | |
* @size = bounce size (sample: 10) | |
* @onFrames = % time on frames (for delay or other effect 0-100) (sample: 50) | |
*/ | |
function buildFrames(size, onFrames) | |
{ | |
var source = ["0", "60", "83", "100", "114", "124", "128", "128", "124", "114", "100", "83", "60", "32", "0", "0", "18", "28", "32", "28", "18", "0"]; | |
var multipler = []; | |
source.forEach(function(i){ | |
multipler.push(i/128); | |
}); | |
var sizes = []; | |
multipler.forEach(function(i){ | |
sizes.push(i*size); | |
}); | |
var timing = []; | |
var rate = 100/30; | |
var framerate = onFrames/30; | |
var result = []; | |
sizes.forEach(function(i, idx){ | |
result.push((idx*framerate).toFixed(2)+"% { margin-top:-"+ i +"px; }"); | |
}); | |
result.forEach(function(i){ console.log(i) }); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment