Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-29-2012, 09:23 PM   PM User | #1
schnarkle
New to the CF scene

 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
schnarkle is an unknown quantity at this point
Help with image rotation slide show

Hello,

I inherited taking over a site and the main page has a slide show of 4 images. It is freezing on the last image instead of looping. Can anyone help?

Code:
Code:
function rotateImages( imageList, imageInterval ){
  if( imageInterval == null ) {
    var imageInterval = 7000;
  }
  var myImageItem = imageList + "> li.imageItem";
  var fadeInTime = 500;
  var imageFadeTime = 2500;
  //var imageCount = $( myImageItem ).length;
  var imageCount = 4;
  var currentImage = 0;
  
  // set up first item
  $( myImageItem ).eq(currentImage).fadeIn(imageFadeTime);
  
  
  // loop through images
  var theBigLoop = setInterval( function() {
    $( myImageItem ).eq(currentImage).fadeOut(imageFadeTime);
    if( currentImage == imageCount ){
        currentImage = 0;
    } else { 
        currentImage++;
    }
    $( myImageItem ).eq(currentImage).fadeIn(imageFadeTime);
      }, imageInterval); // end of setInterval
  
} // end of rotateImages
The site is here: http://www.crunchpak.com

thanks!
Reply With Quote
schnarkle is offline   Reply With Quote
Old 07-01-2012, 08:52 AM   PM User | #2
hdewantara
Regular Coder

 
hdewantara's Avatar
 
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 Posts
hdewantara is an unknown quantity at this point
You could make that currentImage global, by removing the "var" from its line (see the bolded words below):
Code:
function rotateImages( imageList, imageInterval ){
  ...
  currentImage = 0;
  ...
Or maybe this one:
Code:
var currentImage = 0;
function rotateImages( imageList, imageInterval ){
  ...
    //var currentImage = 0;
  ..
hdewantara is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:23 PM.


Advertisement
Log in to turn off these ads.