forked from jquery-backstretch/jquery-backstretch
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an example of how to create a slideshow.
- Loading branch information
Showing
3 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<style> | ||
body { font-family: Helvetica, Arial, sans-serif; } | ||
.container { | ||
width: 90%; | ||
margin: 20px auto; | ||
background-color: #FFF; | ||
padding: 20px; | ||
} | ||
pre { border: 1px solid #CCC; background-color: #EEE; color: #333; padding: 10px; } | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Slideshow Demo</h1> | ||
<p>This demonstrates a commonly-asked question: how do I use Backstretch to create a slideshow of background images?</p> | ||
<pre><code> | ||
<script src="../lib/jquery-1.6.2.min.js"></script> | ||
<script src="../jquery.backstretch.min.js"></script> | ||
<script> | ||
// Create an array of images that you'd like to use | ||
var images = [ | ||
"pot-holder.jpg", | ||
"coffee.jpg" | ||
]; | ||
// The index variable will keep track of which image is currently showing | ||
var index = 0; | ||
|
||
// Call backstretch for the first time, | ||
// In this case, I'm settings speed of 500ms for a fadeIn effect between images. | ||
$.backstretch(images[index], {speed: 500}); | ||
|
||
// Set an interval that increments the index and sets the new image | ||
// Note: The fadeIn speed set above will be inherited | ||
setInterval(function() { | ||
index = (index >= images.length - 1) ? 0 : index + 1; | ||
$.backstretch(images[index]); | ||
}, 5000); | ||
</script> | ||
</code></pre> | ||
</div> | ||
<script src="../lib/jquery-1.6.2.min.js"></script> | ||
<script src="../jquery.backstretch.min.js"></script> | ||
<script> | ||
// Create an array of images that you'd like to use | ||
var images = [ | ||
"pot-holder.jpg", | ||
"coffee.jpg" | ||
]; | ||
// The index variable will keep track of which image is currently showing | ||
var index = 0; | ||
|
||
// Call backstretch for the first time, | ||
// In this case, I'm settings speed of 500ms for a fadeIn effect between images. | ||
$.backstretch(images[index], {speed: 500}); | ||
|
||
// Set an interval that increments the index and sets the new image | ||
// Note: The fadeIn speed set above will be inherited | ||
setInterval(function() { | ||
index = (index >= images.length - 1) ? 0 : index + 1; | ||
$.backstretch(images[index]); | ||
}, 5000); | ||
</script> | ||
</body> | ||
</html> |