Skip to content

Instantly share code, notes, and snippets.

Created December 13, 2013 23:51
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 anonymous/e0670023090aec30d889 to your computer and use it in GitHub Desktop.
Save anonymous/e0670023090aec30d889 to your computer and use it in GitHub Desktop.
window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
if (isAnimationSupported()) {
//Create CssAnimationClass and play
} else {
//Fallback to js animations
requestAnimationFrame(animateCarouselBubbleIn)
}
var start = null;
function animateCarouselBubbleIn(timestamp) {
var progress;
if (start === null) {
start = timestamp;
}
progress = Math.min((timestamp - start) / 600, 1); //Percent progress
bubbleEl.style.left = (1 - progress) * -150 + "%";
bubbleEl.style.top = (1 - progress) * 25 + "%";
bubbleEl.style.height = .9 * (progress * origHeight) + .1 * origHeight + "%" //Add .1 since the CSS3 animation starts from scale .1
bubbleEl.style.width = .9 * (progress * origWidth) + .1 * origHeight + "%"
if (progress < 1) {
requestAnimationFrame(animateCarouselBubbleIn);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment