Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Merge pull request #428 from muffinresearch/wrap-scrollto-with-timeou…
Browse files Browse the repository at this point in the history
…t-android

Wrap scrollTo in setTimeout for android (bug 986625)
  • Loading branch information
muffinresearch committed Apr 1, 2014
2 parents 14b9fab + 9551862 commit 5dbabb8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions hearth/media/js/navigation.js
Expand Up @@ -10,6 +10,7 @@ define('navigation',
{path: '/', type: 'root'}
];
var initialized = false;
var scrollTimer;

function extract_nav_url(url) {
// This function returns the URL that we should use for navigation.
Expand Down Expand Up @@ -71,8 +72,20 @@ define('navigation',
top = state.scrollTop;
}

console.log('Setting scroll immediately to ', top);
window.scrollTo(0, top);
// For android a small delay is required.
if (capabilities.firefoxAndroid) {
if (scrollTimer) {
window.clearTimeout(scrollTimer);
}
scrollTimer = window.setTimeout(function() {
console.log('Setting scroll to', top);
window.scrollTo(0, top);
}, 250);
// For everything else we scroll immediately.
} else {
console.log('Setting scroll immediately to ', top);
window.scrollTo(0, top);
}

// Clean the path's parameters.
// /foo/bar?foo=bar&q=blah -> /foo/bar?q=blah
Expand Down

0 comments on commit 5dbabb8

Please sign in to comment.