mirror of
https://github.com/Polymer/polymer-starter-kit.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #316 from PolymerElements/scroll-to-top
Scroll to top when changing pages (fixes: #202, #285)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user