PDA

View Full Version : Simple Controls Gallery - stop loop



limniad
01-02-2009, 08:01 PM
Simple Controls Gallery

http://www.dynamicdrive.com/dynamicindex4/simplegallery.htm

Hey,

I'd like the slideshow to stop looping after playing through once. Haven't had any successful attempts at creating a loop: false setting. Any suggestions?

ddadmin
01-02-2009, 11:02 PM
There are a few ways to do this. One of them that doesn't modify the .js file in any way is to use the onslide() event handler of the script like so:


var mygallery=new simpleGallery({
wrapperid: "simplegallery1", //ID of main gallery container,
dimensions: [250, 180], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
imagearray: [
["http://i26.tinypic.com/11l7ls0.jpg", "http://en.wikipedia.org/wiki/Swimming_pool", "_new"],
["http://i29.tinypic.com/xp3hns.jpg", "http://en.wikipedia.org/wiki/Cave", ""],
["http://i30.tinypic.com/531q3n.jpg", "", ""],
["http://i31.tinypic.com/119w28m.jpg", "", ""]
],
autoplay: true,
persist: false,
pause: 2500, //pause between slides (milliseconds)
fadeduration: 500, //transition duration (milliseconds)
oninit:function(){ //event that fires when gallery has initialized/ ready to run
},
onslide:function(curslide, i){ //event that fires after each slide is shown
//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
if (i==3)
mygallery.navigate("playpause")
}
})

Here I'm assuming:

1) The 4th slide is the last slide within your gallery (i==3). Remember, i starts at 0.

2) That you have persist: false in the above. Otherwise, the last slide won't always be the 4th slide due to persistence of the last viewed slide.

3) mygallery.navigate("playpause") should correspond to the this gallery instance's name.