Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    376
    Thanks
    9
    Thanked 55 Times in 54 Posts
    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;
      ..


  •  

    Posting Permissions

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