Blending Image Slideshow Script - How do I stop loop?

Discussion in 'JavaScript' started by txwebdesign, Oct 8, 2009.

  1. #1
    txwebdesign, Oct 8, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    this is a horrible little script...

    it's not written badly, considering when that happened. but you should NOT use scripts from dynamic drive, rule of thumb.

    to stop it from looping, find:
    
        whichlink = whichimage
        whichimage = (whichimage<slideimages.length-1)? whichimage+1 : 0
        setTimeout("slideit()",slidespeed+blenddelay)
    
    PHP:
    this increments the counter to +1 until it reaches the end of the images list, then sets to 0.

    the next line goes and self calls the script which will read the nextimage again as the first one.

    you can do:
    
        whichlink = whichimage
        whichimage = (whichimage<slideimages.length-1)? whichimage+1 : 0
        
        if (whichimage) 
            setTimeout(slideit, slidespeed+blenddelay);
    
    PHP:
    basically if whichimage is > 0 it will evaluate as true hence it will queue up the next execution cycle. once it becomes 0, this will evaluate as false which will break it. notice i have removed the " " around the slide it call in the setTimeout, this has performance issues evaluating the string otherwise.

    what does this do anyway, swap between images as like a slideshow? the fade effect applied would only work on IE as well... and the transition won't be smooth etc. it can use a preloader also... anyway, good luck :)
     
    dimitar christoff, Oct 9, 2009 IP
  3. semantic7

    semantic7 Member

    Messages:
    92
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    48
    #3
    So you want it to go through the sequence once and stop ?
     
    semantic7, Oct 11, 2009 IP
  4. txwebdesign

    txwebdesign Peon

    Messages:
    123
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I tried that - it didn't work. Do you have another referral to a Javascript slideshow animation?

    Thanks!
     
    txwebdesign, Oct 13, 2009 IP
  5. txwebdesign

    txwebdesign Peon

    Messages:
    123
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    semantic7 - yes, I just want it to run once. Any ideas?
     
    txwebdesign, Oct 13, 2009 IP