Home
Dynamic Content
Here
|
Categories
Other Sections
Sweet Ads
Compatibility
|
|
FF2+ IE8+ Opera 9+
Card Deck Slideshow Author:
Description: This content slideshow script utilizes CSS3 transform to rotate and "unhinge" each slide to show the next, similar to a stacked pile of cards. At the heart of it all, however, is a versatile slideshow that supports both auto and manual mode, persistence of the last viewed slide, inline or ajax content, and more. The "unhinge" effect works in all browsers that support CSS3 transform, namely, IE10, all modern versions of FF, Chrome, and Safari, including their mobile versions. In non supporting browsers (such as IE9), a standard slide down effect is employed instead. Lets list the essential features of this script now:
Demos (responds to left/right arrow keys):
Step 1: Insert the following code in the HEAD section of your page The code above references one CSS file plus two external .js files, which you need to download below (right click/ select "Save As"):
By default, upload these three files to the same directory as where your webpage resides. Step 2: Insert the below sample code into the BODY section of your page: It contains the HTML for the three demos you see above. That's it for installation! Lets move on to understanding how everything works. HTML Markup of slideshowTo set up a card deck slideshow, first, define the HTML markup for it, which looks like the following: <div id="demo1"
class="stackcontainer"> It should consist of a master DIV container with an arbitrary
but unique ID and a CSS class name of " <div class="inner"> Per the CSS defined inside carddeckslideshow.css, this will supply a padding of 8px to the content defined inside this DIV. If your content is simply an image, you probably don't want any padding around it, and hence should remove the DIV in red. Now, if you wish to define the slideshow contents inside an
external file (and fetched via Ajax by the script), you still need to define the
outermost " <div id="demo1"
class="stackcontainer"> The contents are then defined inside an external file, and pointed to inside the corresponding initialization code (see below). Calling the initialization codeMoving on, you now need to call the initialization function
<script type="text/javascript"> Notice the variable name in red (ie: demo1)- when initializing your slideshow, you should assign the result to an unique but arbitrary variable name for each instance of card deck slideshow on your page. This way you can then use this variable as the starting point to further manipulating the slideshow, by calling one of its methods. Available Options for
|
| option | Description |
hingepoint: stringdefaults to "top left" |
The point within the slideshow container where each slide "unhinges" to reveal the next one. Accepts any valid "x-axis y-axis" string value that CSS's transform-origin property accepts, such as "bottom left", "top right", "40% 50%" etc. |
autplay: Booleandefaults to false |
Boolean on whether slideshow should
auto play when the page loads. If set to true, also configure "cycles"
option below. |
cycles: intdefaults to 2 |
When autoplay is set to
true, sets the number of complete cycles before the slideshow stops
auto rotating. Set this option to 0 to have it run perpetually. |
pause: intdefaults to 3000 |
When autoplay is set to
true, sets the pause in milliseconds between slide changes. |
persist: Booleandefaults to 3000 |
Boolean on whether slideshow should persist within a browser session the last slide shown when the page is reloaded or navigated away from, and recall that slide to show upon return. |
fxduration: intdefaults to 1200 |
Sets the duration in milliseconds of the "unhinge" effect. |
source: "string"defaults to "inline" |
Dictates the source of the contents for
the slideshow. If set to "inline" (default), they should be defined
inline inside the slideshow container. Otherwise, set this option to
the full path to the external file on your server (relative to the
current page) where the same contents are defined inside:
var demo3 = new carddeckslideshow({ Regardless of where your contents are defined, they should
consist of a series of HTML each wrapped around a |
activeclass: "string"defaults to "hinge" |
A CSS class that's added to the
currently "unhinging" slide. Use it to add additional CSS styling to
the presently swapped out slide, such as add a CSS shadow to give it
a raised effect. See inside
carddeckslideshow.css for the style currently added to the "hinge"
class. |
onunhinge: function() |
A callback function invoked at the end
of each slide's unveiling to reveal a new slide, including when the
very first slide is shown when the page first loads (with no
animation). Use this function to add custom code to be called
whenever a slide is shown. It is automatically passed the following
two parameters for your convenience:
For example, the following makes use of the onunhinge:function(curindex, previndex){ As you can see then, the jQuery method |
| Method | |
userplay() |
Plays the slideshow (so it rotates automatically). |
userpause() |
Stops/ pauses a slideshow that's currently playing. |
navigate(keyword) |
Lets you increment/ decrement or jump
to a particular slide on demand. keyword can consist of one of the
following:
If the slideshow is currently auto playing, calling |
getajaxcontent(url) |
Replaces whatever contents the
slideshow is currently showing with those inside the external file
as dictated by the url parameter. Reinitializes the slideshow and
shows the newly fetched contents. For example: <script type="text/javascript"> |