Okay
  Public Ticket #314311
One Page Scrolling
Closed

Comments

  • Rich started the conversation

    Hello,

    I set up one page scrolling on the Join and About pages of the listed website, but it doesn't account for padding of headers when it scrolls to the anchor tag. Are there any ways around this?

    Also, are you guys planning on releasing an update that includes the ability to use single page scrolling across different pages?

    In my menu URLs, I write them as: '/join#chapters', but it doesn't have the desired effect. If I don't write it that way, and I simply use '#chapters' as my URL, it won't link to it properly from other pages.

    Any assistance you can provide would be extremely helpful.

    Thanks,

    Rich

  •  1,071
    ThemeNectar replied

    Hey Rich!

    I actually am seeing the page scroll to correct location above the header when checking out your sections such as

    http://movementexchanges.org/about/#meettheteam

    Also if you're trying to link to other pages which have anchors try using the full URL such as what I posted above

    Cheers


  • Rich replied

    Hi, thanks for your response (and sorry it took so long for my reply).

    I just opted to turn off the single page scrolling feature and wrote the following code, which works like a charm for me:

    var $document = $(document);
    var $window   = $(window);
    
    function scrollToElement( hash ){
      $('html, body').animate({scrollTop: $(hash).offset().top - $('#top').height()}, 300);
    }
    
    $('a').click(function(e){
      var href, hash;
    
      setTimeout(function(){ 
        href = window.location.href;
        hash = window.location.hash;
    
        if ( hash === e.target.hash && href === e.target.href ){
          scrollToElement( hash );
        }
      }, 0);
    
    });
    
    $window.load(function(){
      scrollToElement( window.location.hash );
    });
    
  •  1,071
    ThemeNectar replied

    Hey! I'm glad you got it working and thanks for sharing the code :)