JavaScript: Thumbnail Slider


SUBMITTED BY: Guest

DATE: Feb. 17, 2014, 4:03 p.m.

FORMAT: Text only

SIZE: 2.3 kB

HITS: 738

  1. Description: Thumbnail Slider lets you specify a list of images to showcase then automatically creates a two column interface with thumbnails of the images on the right and the enlarged image on the left to view on demand. Move the mouse over a thumbnail to view the larger version. The script supports the following features:
  2. Simply define the images to show, and the script automatically creates the entire interface that makes up the slider.
  3. Automatic or manual sliding
  4. If automatic cycling, whether to stop after x cycles, and also, when the user clicks on a thumbnail
  5. Enlarged image is centered within the viewport
  6. Directions:
  7. Step 1: Insert the below into the <head> section of your page:
  8. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  9. <script type="text/javascript" src="thumbslide.js">
  10. </script>
  11. <link rel="stylesheet" type="text/css" href="thumbslide.css" />
  12. <script>
  13. //Initialization code:
  14. $(document).ready(function(){ // on document load
  15. $("#thumbsliderdiv").imageSlider({ //initialize slider
  16. 'thumbs': ["fpslideshow/church.jpg","fpslideshow/fisherman.jpg","fpslideshow/legs.jpg","fpslideshow/sunset.jpg","fpslideshow/tropical.jpg","livingroom.jpg","livingroom2.jpg"], // file names of images within slider. Default path should be changed inside thumbslide.js (near bottom)
  17. 'auto_scroll':true,
  18. 'auto_scroll_speed':4500,
  19. 'stop_after': 2, //stop after x cycles? Set to 0 to disable.
  20. 'canvas_width':700,
  21. 'canvas_height':500 // <-- No comma after last option
  22. })
  23. });
  24. </script>
  25. The above code references the following 3 files, which you should download below:
  26. thumbslide.js
  27. thumbslide.css
  28. Image at> http://www.javascriptkit.com/script/script2/selected.gif
  29. Step 2: Where you wish the slider to appear in the BODY of your page, insert an empty DIV with a ID attribute. The value of the attribute should match that defined inside the initialization code (more on that later).
  30. <div id="thumbsliderdiv"></div>
  31. That's it- the script will do the rest in populating this DIV with the entire interface that makes up the slider.

comments powered by Disqus