SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Jun 5, 2007, 18:32 #1
- Join Date
- May 2004
- Location
- Richmond, VA, USA
- Posts
- 819
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Image rotator help. Uses scrptaculous and prototype
I'm much better at php than javascript, and I'm having some problems getting images to rotate using the scriptaculous libraries.
It's better to see it, you should be able to tell what I'm trying to do.
http://richsculpture.com/index.php?richard=allow
The homepage pretty much works correctly. Click on gallery and it seems like it's just switching them randomly. Seems like it has problems when it uses multiple sets of images.
Here's the code I wrote...
Code JavaScript:function runPortal(portal_number){ var portal = document.getElementById('portal'+portal_number); // represents the div that holds the images var thumbs = portal.getElementsByTagName('a'); // represents all the images within the div that will be rotated // Hide everything for (var i=0;i<thumbs.length;i++){ if (i==0) continue; // Don't hide the first one thumbs[i].childNodes[0].style.display = 'none'; } // Set up the image rotator var rotator = new PeriodicalExecuter(nextImage, 2); rotator.i = 0; rotator.last=0; rotator.thumbs = thumbs; } function nextImage(){ if (this.i == this.thumbs.length){ this.i = 0; } Effect.Appear(this.thumbs[this.i].childNodes[0]); Effect.dglPuff(this.thumbs[this.last].childNodes[0], {duration:.6, from:.7}); this.last = this.i; this.i++; }
Can anyone help? Let me know if I was unclear at all.
-
Jun 5, 2007, 21:47 #2
- Join Date
- May 2004
- Location
- Richmond, VA, USA
- Posts
- 819
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
So, I checked it out in IE7 and it seems to be working flawlessly.
Any Firefox specific stuff that could be throwing me off?
-
Jun 5, 2007, 22:40 #3
- Join Date
- May 2004
- Location
- Richmond, VA, USA
- Posts
- 819
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The problem seems to lie with using multiple instances of periodicalExecutor.
I've seen someone else describing my same problem here:
http://dev.rubyonrails.org/ticket/5752
It looks like I'm going to need to write my own code to call the rotator function every x seconds. Unless of course one of you knows where I could find it. (hint, hint)
Bookmarks