SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Twitter - @CarlBeckel busy's Avatar
    Join Date
    May 2004
    Location
    Richmond, VA, USA
    Posts
    819
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question 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.

  2. #2
    Twitter - @CarlBeckel busy's Avatar
    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?

  3. #3
    Twitter - @CarlBeckel busy's Avatar
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •