Auto-Scroll isn't correct

April 2014 WordPress Theme
GK User
Sun May 11, 2014 7:51 pm
Hi,
I have some problems with my site..
When i click on the menu it scrolls down to a section, but it is not stopping at the top of the section..
Instead it scrolls a fed pixels too far.

Is there some way to fix it?

Domain: http://www.niklasw.dk

Niklas
User avatar
Fresh Boarder

GK User
Sun May 11, 2014 9:25 pm
Please edit file:
/wp-content/themes/John/js/gk.scripts.js
find this section:
Code: Select all
// smooth anchor scrolling
       jQuery('a[href^="#"]').on('click',function (e) {
          e.preventDefault();
   
          var target = this.hash,
          target = jQuery(target);
          if(target.parent() !== jQuery('#gk-style-area')) {
             jQuery('html, body').stop().animate({
                'scrollTop': target.offset().top
             }, 1000, 'swing', function () {
                window.location.hash = target.selector;
             });
          }
       });

And modify line:
Code: Select all
'scrollTop': target.offset().top

Adding a offset:
Code: Select all
'scrollTop': target.offset().top - 20


Modify the value to suit your needs.
User avatar
Moderator

GK User
Mon May 12, 2014 8:18 pm
Great thanks.. I will try that! :)
User avatar
Fresh Boarder

GK User
Tue May 13, 2014 12:32 pm
It worked perfectly.. But the selected menu point doesn´t change at that point??
User avatar
Fresh Boarder

GK User
Tue May 13, 2014 4:32 pm
I don't see suggested change in your gk.scripts.js file
User avatar
Moderator

GK User
Mon Jan 12, 2015 11:20 am
This is what I needed! Thanks! :D
User avatar
Expert Boarder

GK User
Tue Jan 13, 2015 6:07 pm
No problem :). It's always nice to see users searching through available threads.
User avatar
Moderator


cron
Remember me
Register New Account
If you are old Gavick user, click HERE for steps to retrieve your account.