Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: chrome/browser/resources/settings/settings_page/main_page_behavior.js

Issue 2582643002: MD Settings: Fix scrolling when navigating Forwards from BASIC page. (Closed)
Patch Set: change code Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/basic_page_browsertest.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Responds to route changes by expanding, collapsing, or scrolling to sections 6 * Responds to route changes by expanding, collapsing, or scrolling to sections
7 * on the page. Expanded sections take up the full height of the container. At 7 * on the page. Expanded sections take up the full height of the container. At
8 * most one section should be expanded at any given time. 8 * most one section should be expanded at any given time.
9 * @polymerBehavior MainPageBehavior 9 * @polymerBehavior MainPageBehavior
10 */ 10 */
(...skipping 20 matching lines...) Expand all
31 this.scroller = this.domHost.parentNode.scroller; 31 this.scroller = this.domHost.parentNode.scroller;
32 else 32 else
33 this.scroller = document.body; // Used in unit tests. 33 this.scroller = document.body; // Used in unit tests.
34 }, 34 },
35 35
36 /** 36 /**
37 * @param {!settings.Route} newRoute 37 * @param {!settings.Route} newRoute
38 * @param {settings.Route} oldRoute 38 * @param {settings.Route} oldRoute
39 */ 39 */
40 currentRouteChanged: function(newRoute, oldRoute) { 40 currentRouteChanged: function(newRoute, oldRoute) {
41 // Scroll to the section except for back/forward. Also scroll for any
42 // back/forward navigations that are in-page.
43 var oldRouteWasSection = 41 var oldRouteWasSection =
44 !!oldRoute && !!oldRoute.parent && !!oldRoute.section && 42 !!oldRoute && !!oldRoute.parent && !!oldRoute.section &&
45 oldRoute.parent.section != oldRoute.section; 43 oldRoute.parent.section != oldRoute.section;
46 44
45 // Always scroll to the top if navigating from a section to the root route.
47 if (oldRouteWasSection && newRoute == settings.Route.BASIC) { 46 if (oldRouteWasSection && newRoute == settings.Route.BASIC) {
48 this.scroller.scrollTop = 0; 47 this.scroller.scrollTop = 0;
49 return; 48 return;
50 } 49 }
51 50
51 // Scroll to the section except for back/forward. Also scroll for any
52 // in-page back/forward navigations (from a section or the root page).
52 var scrollToSection = 53 var scrollToSection =
53 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection; 54 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection ||
55 oldRoute == settings.Route.BASIC;
54 56
55 // For previously uncreated pages (including on first load), allow the page 57 // For previously uncreated pages (including on first load), allow the page
56 // to render before scrolling to or expanding the section. 58 // to render before scrolling to or expanding the section.
57 if (!oldRoute || this.scrollHeight == 0) 59 if (!oldRoute || this.scrollHeight == 0)
58 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); 60 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection));
59 else 61 else
60 this.tryTransitionToSection_(scrollToSection); 62 this.tryTransitionToSection_(scrollToSection);
61 }, 63 },
62 64
63 /** 65 /**
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 return /** @type {?SettingsSectionElement} */( 300 return /** @type {?SettingsSectionElement} */(
299 this.$$('settings-section[section="' + section + '"]')); 301 this.$$('settings-section[section="' + section + '"]'));
300 }, 302 },
301 }; 303 };
302 304
303 /** @polymerBehavior */ 305 /** @polymerBehavior */
304 var MainPageBehavior = [ 306 var MainPageBehavior = [
305 settings.RouteObserverBehavior, 307 settings.RouteObserverBehavior,
306 MainPageBehaviorImpl, 308 MainPageBehaviorImpl,
307 ]; 309 ];
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/basic_page_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698