I'm not really sure where else on that page you would want it to scroll to, perhaps my browser is showing it differently. But, if it's not scrolling to where you want it to, you should try to scroll to a different element. This element can be an otherwise unseen span that you just place wherever seems best. If that doesn't fix that, we can talk about using an adjustment to wherever the code takes it. I would add that we are already lucky in a way this has worked at all because the pages we've done this with are laid out and/or scripted in an odd fashion such that they don't scroll in the normal manner.
As for animating and using a separate top for each instance -
OK, our little line inside the script gets more complex. It is currently:
Now let's make it like so:Code:window.scrollTo(0, $('#paginatetop').position().top);
And we have to add something to the main function (again, in the main script, this time near the top):Code:if(this.pagetop){$('html, body').animate({scrollTop: $(this.pagetop).position().top});}
Then when you initialize the script, you declare the selector for the pagination top:Code:function virtualpaginate(config){ //config: {piececlass:, piececontainer:, pieces_per_page:, defaultpage:, wraparound:, persist}this.pagetop = config.pagetopthis.piececlass=config.piececlass var elementType=(typeof config.piececontainer=="undefined")? "div" : config.piececontainer //The type of element used to divide up content into pieces. Defaults to "div" this.pieces=virtualpaginate.collectElementbyClass(config.piececlass, elementType) //get total number of divs matching class name //Set this.chunksize: 1 if "chunksize" param is undefined, "chunksize" if it's less than total pieces available, or simply total pieces avail (show all) this.chunksize=(typeof config.pieces_per_page=="undefined")? 1 : (config.pieces_per_page>0 && config.pieces_per_page<this.pieces.length)? config.pieces_per_page : this.pieces.length this.pagecount=Math.ceil(this.pieces.length/this.chunksize) //calculate number of "pages" needed to show the divs this.wraparound=config.wraparound || false this.paginatediv=[], this.flatviewlinks=[], this.cpspan=[], this.selectmenu=[], this.prevlinks=[], this.nextlinks=[] this.persist=config.persist var persistedpage=virtualpaginate.getCookie("dd_"+this.piececlass) || 0 var urlselectedpage=virtualpaginate.urlparamselect(this.piececlass) //returns null or index from: mypage.htm?piececlass=index this.currentpage=(typeof urlselectedpage=="number")? urlselectedpage : ((this.persist)? persistedpage : config.defaultpage) this.currentpage=(this.currentpage<this.pagecount)? parseInt(this.currentpage) : 0 //ensure currentpage is within range of available pages this.showpage(this.currentpage) //Show selected page }
Code:<script type="text/javascript"> var gallery=new virtualpaginate({ piececlass: "virtualpage", piececontainer: 'div',pagetop: '#paginatetop',pieces_per_page: 1, defaultpage: 0, wraparound: false, persist: true }) gallery.buildpagination(["gallerypaginate", "gallerypaginate2"])



Reply With Quote
Bookmarks