473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to get the slideshow effect using javascript on my website?

I am trying to get a "slideshow" effect on my website. I have plenty of examples of it, but I cannot for the life of me find a tutorial on programming it.

Examples would include:

http://www.sibfox.com/

http://www.crunchyroll.com/

Both of these sites have a slideshow that has the little markers on the bottom right.

Ideally I want one like www.crunchyroll.com has.

I THINK the coding is as follows (from Sibfox.com):

Expand|Select|Wrap|Line Numbers
  1.         <div id="gal">
  2.  
  3. <div id="pics_list"><div><ul><li><img src="/data/catalog/9_thumb.jpg" width="758" height="342" /></li><li><img src="/data/catalog/10_thumb.jpg" width="758" height="342" /></li><li><img src="/data/catalog/11_thumb.jpg" width="758" height="342" /></li><li><img src="/data/catalog/12_thumb.jpg" width="758" height="342" /></li><li><img src="/data/catalog/13_thumb.jpg" width="758" height="342" /></li></ul></div></div><div id="pics_menu"><a href="#"></a><a href="#"></a><a href="#"></a><a href="#"></a><a href="#"></a>
  4.  
  5. </div>
  6.  
  7. </div>
  8.  
  9.  
While the Javascript coding is as follows:

Expand|Select|Wrap|Line Numbers
  1. var galbuts;
  2. var active;
  3. var cur_cycle;
  4. var cycle_timeout;
  5. var pics_list;
  6.  
  7. function isInt(x) { 
  8.    var y=parseInt(x); 
  9.    if (isNaN(y)) return false; 
  10.    return x==y && x.toString()==y.toString(); 
  11.  
  12. function findA(aLink) {
  13.     for (var i=0; i<galbuts.length; i++) {
  14.         if (aLink == galbuts[i]) {
  15.             return i;
  16.         }
  17.     }
  18. }
  19.  
  20. function gotoPic(index) {
  21.     if (active == index) return;
  22.     if (isInt(active)) {
  23.         goWhite(galbuts[active]);
  24.     }
  25.     active = index;
  26.     pics_list.morph({'marginLeft': index*-1*758});
  27.     goRed(galbuts[index]);
  28. }
  29.  
  30. function toMine() {
  31.     var a_index = findA(this);
  32.     gotoPic(a_index);
  33.     clearTimeout(cycle_timeout);
  34.     cycle_timeout = setTimeout(cycle, 7500);
  35.     cur_cycle = a_index;
  36.     return false;
  37. }
  38.  
  39. function cycle() {
  40.     if (cur_cycle == galbuts.length-1) {
  41.         cur_cycle = 0;
  42.     } else {
  43.         cur_cycle++;
  44.     }
  45.     gotoPic(cur_cycle);
  46.     cycle_timeout = setTimeout(cycle, 5000);
  47. }
  48.  
  49. function goRed(el) {
  50.     el.setStyle('backgroundPosition', '0 -16px');
  51. }
  52.  
  53. function goWhite(el) {
  54.     el.setStyle('backgroundPosition', '0 -0');
  55. }
  56.  
  57.  
  58. window.addEvent('domready', function()
  59. {
  60.         $('keyword').addEvents({                                     
  61.                                    'focus' : function(){  if (this.value=='search...') this.value='' },
  62.                                     'blur' : function() { if (this.value=='') this.value='search...' }
  63.  
  64.                                  });
  65.  
  66.     galbuts = $('pics_menu').getElements('a').reverse();    
  67.     pics_list = $('pics_list').getElement('div');
  68.     pics_list.set('morph', {duration: 750, transition: Fx.Transitions.Quad.easeInOut});    
  69.     goRed(galbuts[0]);
  70.     cur_cycle = 0;
  71.     active = 0;
  72.     cycle_timeout = setTimeout(cycle, 5000);
  73.     for (var i=0; i<galbuts.length; i++) {
  74.         galbuts[i].set('morph', {duration: 350});
  75.         galbuts[i].addEvents({
  76.                                      'mouseleave': function(){
  77.                                                             if (findA(this) != active) {
  78.                                                                 goWhite(this);
  79.                                                             }
  80.                                                        },
  81.                                      'mouseover' : function(){
  82.                                                              if (findA(this) != active) {
  83.                                                                 goRed(this);
  84.                                                             }
  85.                                                        },
  86.                                      'click'     : toMine
  87.                                      });
  88.     }
  89.     $$(document.links).filter(function(el) {
  90.         return el.rel && el.rel.test(/^lightbox/i);
  91.     }).slimbox({/* Put custom options here */}, null, function(el) {
  92.         return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
  93.     });
  94. }
  95. );
  96.  
  97.  
Please let me know how I could customize this (including how to change size of window, how to alter the shape of the tracker in bottom right, and how to add a text box over the picture like Crunchyroll's site has. Preferably, I would like a website with the details but I can't find anything specific on this item at w3.

Thank you in advance,
Wesley
Mar 28 '11 #1
1 1767
There is a really good example of how to do this in Chapter 4 of "jQuery Novice to Ninja". The source is available from http://www.sitepoint.com/books/jquery1/code.php - it's really rather simple!
Mar 30 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Silvio | last post by:
Here's my update statement: UPDATE Item1 SET reviewloop = 1, currentreviewstate=5 WHERE itemid in (SELECT itemid FROM Item2) The thing is: the table Item2 DOES NOT HAVE a field called...
1
by: john | last post by:
Hello, I am trying to create a delegate for an upgrade but I am now getting this error: Method 'Public Function CamEventCallbackFunc(eventID As Integer, pData As Integer, DataSize As Integer,...
1
by: Arun | last post by:
Hi, I've got a managed class , inside which I'm instantiating an unmanaged class. If that class has some virtual methods, then while debugging I couldn't jump into the source of that virtual...
2
by: Bruno Alexandre | last post by:
Hi guys, does anyone know where is the Website used in the MSDN "Lear ASP.NET 2.0 with Jeff Prosise" (http://msdn.microsoft.com/asp.net/beta2/multimedia/default.aspx) events? The website used...
0
by: mark | last post by:
Printing algorithms in VB.NET are a nuisance, particularly for tables, grids and other extended arrays. Does anyone know of astraightforward , third party Class Library - preferably with source...
15
by: Pucca | last post by:
I'm getting an error when I tried to use this BerConverter class in my C# code. Even though the Interent doc says that it runs on Win2000 sp4, I just thgouth I'll double check. Does anyone know...
0
by: Bruce One | last post by:
I need a VS2005 AddIn to deal with files XLS, CSV, TXT and XML, in such a way I may be able to determine previously its layout. I should be able to import or export it... Does anyone know this...
12
by: Philip | last post by:
Does anyone know any commercial C++/CLI GUI library with source code? Thank you very much.
0
by: DR | last post by:
I heard there is some trick to referencing statics in C# CLR stored procedure without having to mark the assembly as unsafe. Does anyone know this? This is usefull as the case of needing a little...
3
by: DR | last post by:
I heard there is some trick to referencing statics in VB.NET CLR stored procedure without having to mark the assembly as unsafe. Does anyone know this? This is usefull as the case of needing a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.