Skip to content

Instantly share code, notes, and snippets.

@sivagao
Created July 18, 2013 22:35
Show Gist options
  • Save sivagao/6033704 to your computer and use it in GitHub Desktop.
Save sivagao/6033704 to your computer and use it in GitHub Desktop.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="jquery.backstretch.min.js"></script>
<script>
// To attach Backstrech as the body's background
$.backstretch("path/to/image.jpg");
// You may also attach Backstretch to a block-level element
$(".foo").backstretch("path/to/image.jpg");
// Or, to start a slideshow, just pass in an array of images
$(".foo").backstretch([
"path/to/image.jpg",
"path/to/image2.jpg",
"path/to/image3.jpg"
], {duration: 4000});
// Access the instance
var instance = $('.foo').data('backstretch');
// Then, you can manipulate the images array directly
instance.images.push('path/to/image4.jpg')
// Pause the slideshow
$('.foo').backstretch("pause");
// Advance to the next slide
$('.foo').backstretch("next");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment