scrollTop moody #52

arvgta opened this Issue Mar 30, 2015 · 0 comments


None yet

1 participant

arvgta commented Mar 30, 2015
$('html, body').animate({ 
        scrollTop: $('#' + url.split('#')[1]).offset().top
    }, 500);

The above code works, when a link with a '#' is pressed after the new page has been loaded beforehand e.g. in "Recent Comments" (in the sidebar) on

It doesn't work though when clicking e.g. "Google Analytics handling documented" on the homepage of (with the following URL: (If I dump the URL into the browsers address bar, it works)

A scroll is performed, but to the very bottom of the page...

Any ideas why?

I have provided the id like this:

<h1 id="gasetup"><span style="color: #008000;">Google Analytics Setup</span></h1>

EDIT: Now using the following up-to-date Pronto code:

var $el = $('#' + url.split('#')[1]), scrollTop;

if ($el.length) {
    scrollTop = $el.offset().top;

if (scrollTop !== false) {

The same result as above

So, I reckon that parts of the "ajaxification" interfere with calculating the offset...
But what could that be??

EDIT. Solved(presumably)

The second animate() was running in the background, while the scroll was being performed.
Solved by introducing the function _doRender2() as a callback in the animate() call...

Test file

@arvgta arvgta closed this Apr 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment