Skip to content

Instantly share code, notes, and snippets.

@justinhough
Created May 20, 2015 01:54
Show Gist options
  • Save justinhough/42dcb8e7fa6f59bf34b2 to your computer and use it in GitHub Desktop.
Save justinhough/42dcb8e7fa6f59bf34b2 to your computer and use it in GitHub Desktop.
Add zoom animation to background image.
#main-banner {
background-size:55% auto;
background-position:center 0;
}
function zoomInBanner(zoomItem, first, second, timing){
$(zoomItem).animate({ 'background-size' : first }, timing)
.animate({ 'background-size' : second }, timing,
function(){
setTimeout(zoomInBanner(zoomItem, first, second), 4000);
});
}
$(document).ready(function(){
// set id or class of element, zoom to percentage, reset zoom (same value in CSS), and timing
zoomInBanner('#main-banner', '65%', '55%', 8000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment