Page 3 of 3 FirstFirst 123
Results 21 to 21 of 21

Thread: Virtual Pagination script: jump to top next content

  1. #21
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    window.scrollTo(0, $('#paginatetop').position().top);
    Now let's make it like so:

    Code:
    if(this.pagetop){$('html, body').animate({scrollTop: $(this.pagetop).position().top});}
    And we have to add something to the main function (again, in the main script, this time near the top):

    Code:
    function virtualpaginate(config){ //config: {piececlass:, piececontainer:, pieces_per_page:, defaultpage:, wraparound:, persist}
    	this.pagetop = config.pagetop
    	this.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
    }
    Then when you initialize the script, you declare the selector for the pagination top:

    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"])
    Last edited by jscheuer1; 09-29-2017 at 04:53 PM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  2. The Following User Says Thank You to jscheuer1 For This Useful Post:

    chechu (11-25-2017)

Similar Threads

  1. Virtual Pagination script v2.0
    By chas in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 06-01-2009, 02:23 AM
  2. Help with Merging Virtual Pagination & Scrollable Content Scripts
    By mmalik in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 01-02-2009, 06:08 PM
  3. Virtual Pagination within Tabbed Content
    By touchnova in forum Dynamic Drive scripts help
    Replies: 11
    Last Post: 09-13-2008, 03:31 PM
  4. Virtual pagination and run active content
    By orion3000 in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 01-15-2008, 04:52 AM
  5. Altering a content loop script for Virtual Pagination
    By JBottero in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 06-03-2007, 07:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •