3
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by Troy III
0

Try this - seems fine to me; you can hack into the JavaScript if you want to adjust the speed!

http://www.kryogenix.org/code/browser/smoothscroll/#p3
http://www.kryogenix.org/code/browser/smoothscroll/smoothscroll.js

// Now loop all A tags until we find one with that name
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }

I'm not sure if JS has a function to make the process "wait" for sometime, but if you do - I guess it goes somewhere in here.

Edited by dantinkakkar: put code

1

Hi all,

I'm using scrollintoview to scroll to the element but it's very quick, do you know anything like this but smooth?

That's not because it is quick. The 'scrollIntoView' method doesn't actually scroll. It only makes the target jump strait into view.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.