Hi all,

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

Recommended Answers

All 2 Replies

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.