Merge pull request #316 from PolymerElements/scroll-to-top

Scroll to top when changing pages (fixes: #202, #285)
This commit is contained in:
Addy Osmani
2015-08-21 17:06:33 +01:00
2 changed files with 9 additions and 0 deletions

View File

@@ -17,19 +17,23 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// More info: https://visionmedia.github.io/page.js/
page('/', function () {
app.route = 'home';
app.scrollPageToTop();
});
page('/users', function () {
app.route = 'users';
app.scrollPageToTop();
});
page('/users/:name', function (data) {
app.route = 'user-info';
app.params = data.params;
app.scrollPageToTop();
});
page('/contact', function () {
app.route = 'contact';
app.scrollPageToTop();
});
// add #! before urls

View File

@@ -66,4 +66,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
};
// Scroll page to top and expand header
app.scrollPageToTop = function() {
document.getElementById('mainContainer').scrollTop = 0;
};
})(document);