Skip to content

Instantly share code, notes, and snippets.

@jaymzcd
Created October 7, 2012 20:37
Show Gist options
  • Select an option

  • Save jaymzcd/3849521 to your computer and use it in GitHub Desktop.

Select an option

Save jaymzcd/3849521 to your computer and use it in GitHub Desktop.
Infinitely scroll the background of an element with jquery
var SCROLL_TIME = 120; // seconds to scroll through
$(document).ready(function () {
var scrollingContent = function() {
console.log("Scrolling background");
$('.container').css('background-position-y', 0);
$('.container').animate({
'background-position-y': -1 * $(this).height()
}, SCROLL_TIME * 1000, 'linear', scrollingContent);
};
scrollingContent();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment