Skip to content

Commit

Permalink
Added an example of how to create a slideshow.
Browse files Browse the repository at this point in the history
  • Loading branch information
srobbin committed Jul 6, 2011
1 parent 1b8fac6 commit b49ce86
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/basic.html
Expand Up @@ -19,7 +19,7 @@ <h1>Basic Demo</h1>
<p>This is a basic demo of jQuery Backstretch. It is a simple example of loading one image onto the page.</p>
<pre><code>
&lt;script src=&quot;../lib/jquery-1.6.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;../jquery.backstretch.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;../jquery.backstretch.min.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
$.backstretch(&quot;pot-holder.jpg&quot;);
&lt;/script&gt;
Expand Down
4 changes: 2 additions & 2 deletions examples/click.html
Expand Up @@ -24,9 +24,9 @@ <h1>Click Demo</h1>
</p>
<pre><code>
&lt;script src=&quot;../lib/jquery-1.6.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;../jquery.backstretch.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;../jquery.backstretch.min.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
$.backstretch(&quot;pot-holder.jpg&quot;, {speed: 250});
$.backstretch(&quot;pot-holder.jpg&quot;, {speed: 500});

$(&quot;#pot-holder&quot;).click(function() {
$.backstretch(&quot;pot-holder.jpg&quot;);
Expand Down
68 changes: 68 additions & 0 deletions examples/slideshow.html
@@ -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>
&lt;script src=&quot;../lib/jquery-1.6.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;../jquery.backstretch.min.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
// Create an array of images that you'd like to use
var images = [
&quot;pot-holder.jpg&quot;,
&quot;coffee.jpg&quot;
];
// 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 &gt;= images.length - 1) ? 0 : index + 1;
$.backstretch(images[index]);
}, 5000);
&lt;/script&gt;
</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>

0 comments on commit b49ce86

Please sign in to comment.