OK, this is in response to a private request by the same person who opened this thread. They want to jump back to the first panel instead of sliding. I'm not sure about all of the ins and outs of this, how it will play out in any given setup (the Viewer is so flexible) but I tried to make it as intuitive as possible, and it could still be tweaked. I prefer the default action of the script though. But to do this, replace the two functions of the same name in the stepcarousel.js file with these (additions highlighted):
Code:
stepTo:function(galleryid, pindex){ /*User entered pindex starts at 1 for intuitiveness. Internally pindex still starts at 0 */
var config=stepcarousel.configholder[galleryid]
if (typeof config=="undefined"){
alert("There's an error with your set up of Carousel Viewer \""+galleryid+ "\"!")
return
}
var pindex=Math.min(pindex-1, config.paneloffsets.length-1)
if(config.currentpanel > 1 && pindex == 0)
config.$belt[0].style.left = 0;
var endpoint=config.paneloffsets[pindex]+(pindex==0? 0 : config.beltoffset)
config.$belt.animate({left: -endpoint+'px'}, 'slow', function(){config.onslideaction(this)})
config.currentpanel=pindex
this.statusreport(galleryid)
},
stepBy:function(galleryid, steps){
var config=stepcarousel.configholder[galleryid]
if (typeof config=="undefined"){
alert("There's an error with your set up of Carousel Viewer \""+galleryid+ "\"!")
return
}
var direction=(steps>0)? 'forward' : 'back' //If "steps" is negative, that means backwards
var pindex=config.currentpanel+steps //index of panel to stop at
pindex=(pindex>config.paneloffsets.length-1 || pindex<0 && pindex-steps>0)? 0 : (pindex<0)? config.paneloffsets.length+steps : pindex //take into account end or starting panel and step direction
var endpoint=config.paneloffsets[pindex]+(pindex==0? 0 : config.beltoffset) //left distance for Belt DIV to travel to
if(config.currentpanel == config.paneloffsets.length -1 && pindex == 0)
config.$belt[0].style.left = 0;
else if (pindex==0 && direction=='forward' || config.currentpanel==0 && direction=='back'){ //decide whether to apply "push pull" effect
config.$belt.animate({left: -config.paneloffsets[config.currentpanel]-(direction=='forward'? 100 : -30)+'px'}, 'normal', function(){
config.$belt.animate({left: -endpoint+'px'}, 'slow', function(){config.onslideaction(this)})
})
}
else
config.$belt.animate({left: -endpoint+'px'}, 'slow', function(){config.onslideaction(this)})
config.currentpanel=pindex
this.statusreport(galleryid)
},
Another option would (I think, haven't really tried that, but it looks like the script can handle it) be to speed up the action just a bit when traversing from last to first, I might like that better, but it is up to you.
Bookmarks