PDA

View Full Version : Possible to navigate to a specific slide?



slemhundy
08-05-2015, 09:08 PM
1) Script Title: ParallaxSlider

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/parallaxslider/index.htm

3) Describe problem:

By default this script allows navigation through back and forth links, but it does not appear to offer any way to link to a specific slide.

This is what I have in my page:


<a href="javascript:firstparallaxslider.navigate('back')">Back</a> | <a href="javascript:firstparallaxslider.navigate('forth')">Forth</a>

And here's the navigate function from parallaxslider.js


navigate:function(keyword){ //keyword: "back" or "forth"
var slideshow=this, setting=this.setting
clearTimeout(this.rotatetimer)
if (!setting.displaymode.stoponclick && setting.displaymode.type!="manual"){ //if slider should continue auto rotating after nav buttons are clicked on
this.curstep=(keyword=="back")? this.curstep-1 : this.curstep+1 //move curstep counter explicitly back or forth depending on direction of slide
this.rotatetimer=setTimeout(function(){slideshow.rotate()}, setting.displaymode.pause)
}
var dir=(keyword=="back")? (setting.orientation=="h"? "right" : "down") : (setting.orientation=="h"? "left" : "up")
var targetslide=(keyword=="back")? this.curslide-1 : this.curslide+1
targetslide=(targetslide<0)? this.$imageslides.length-1 : (targetslide>this.$imageslides.length-1)? 0 : targetslide //wrap around
if (this.animation_isrunning==false)
this.slide(targetslide, dir)
},

Would it be possible to add the ability to navigate directly to a slide by ID or something?

vwphillips
08-07-2015, 01:58 PM
try


navigate:function(keyword){ //keyword: "back" or "forth" or the slide number to goto
var slideshow=this,setting=this.setting, goto=this.$imageslides[keyword];
clearTimeout(this.rotatetimer)
if (!goto&&!setting.displaymode.stoponclick && setting.displaymode.type!="manual"){ //if slider should continue auto rotating after nav buttons are clicked on
this.curstep=(keyword=="back")? this.curstep-1 : this.curstep+1 //move curstep counter explicitly back or forth depending on direction of slide
this.rotatetimer=setTimeout(function(){slideshow.rotate()}, setting.displaymode.pause)
}
var dir=(keyword=="back"||(goto&&keyword<this.curslide))? (setting.orientation=="h"? "right" : "down") : (setting.orientation=="h"? "left" : "up")
var targetslide=(keyword=="back")? this.curslide-1 : this.curslide+1
targetslide=goto?keyword:(targetslide<0)? this.$imageslides.length-1 : (targetslide>this.$imageslides.length-1)? 0 : targetslide //wrap around
if (this.animation_isrunning==false)
this.slide(targetslide, dir)
},




<input type="button" name="" value="GoTo 2" onclick="firstparallaxslider.navigate(2)"/>

slemhundy
08-07-2015, 02:11 PM
This is perfect. Thanks!