Granit
Granit

Reputation: 127

Smooth Scrolling throughout the website

Im trying to make my website scroll smoother throughout the entire website, not just jump from a link to an anchor. Ive been googling about it but i have not found the solution im looking for. Any help?

Upvotes: 1

Views: 103

Answers (2)

Paradoxis
Paradoxis

Reputation: 4708

I think I have a the script you mean, I use it on my own website: https://www.paradoxis.nl.
Just save the file and try it out, it only works on chrome tough.

URL: https://gist.github.com/galambalazs/6477177

<script src="https://gist.githubusercontent.com/galambalazs/6477177/raw/b2a85bb7f79b2721600677525a16a17bc511f1b8/SmoothScroll.js"></script>

Upvotes: 1

Renish Khunt
Renish Khunt

Reputation: 5824

use this function this is working for smooth scroll.

$(function() {
$('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top
        }, 1000);
        return false;
      }
    }
  });
});

don't need to create anything just put this code into your js file it's working automatically.

for more details.

http://css-tricks.com/snippets/jquery/smooth-scrolling/

Upvotes: 1

Related Questions