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

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: 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 var oldRouteWasSection = 43 var oldRouteWasSection =
44 !!oldRoute && !!oldRoute.parent && !!oldRoute.section && 44 !!oldRoute && !!oldRoute.parent && !!oldRoute.section &&
45 oldRoute.parent.section != oldRoute.section; 45 oldRoute.parent.section != oldRoute.section;
46 46
47 if (oldRouteWasSection && newRoute == settings.Route.BASIC) { 47 if (oldRouteWasSection && newRoute == settings.Route.BASIC) {
48 this.scroller.scrollTop = 0; 48 this.scroller.scrollTop = 0;
49 return; 49 return;
50 } 50 }
51 51
52 var scrollToSection = 52 var scrollToSection =
53 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection; 53 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection ||
54 oldRoute == settings.Route.BASIC;
Dan Beam 2016/12/16 00:59:59 can you explain why?
tommycli 2016/12/16 20:17:40 Done. Refactored a bit and expanded comment.
54 55
55 // For previously uncreated pages (including on first load), allow the page 56 // For previously uncreated pages (including on first load), allow the page
56 // to render before scrolling to or expanding the section. 57 // to render before scrolling to or expanding the section.
57 if (!oldRoute || this.scrollHeight == 0) 58 if (!oldRoute || this.scrollHeight == 0)
58 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); 59 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection));
59 else 60 else
60 this.tryTransitionToSection_(scrollToSection); 61 this.tryTransitionToSection_(scrollToSection);
61 }, 62 },
62 63
63 /** 64 /**
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 return /** @type {?SettingsSectionElement} */( 299 return /** @type {?SettingsSectionElement} */(
299 this.$$('settings-section[section="' + section + '"]')); 300 this.$$('settings-section[section="' + section + '"]'));
300 }, 301 },
301 }; 302 };
302 303
303 /** @polymerBehavior */ 304 /** @polymerBehavior */
304 var MainPageBehavior = [ 305 var MainPageBehavior = [
305 settings.RouteObserverBehavior, 306 settings.RouteObserverBehavior,
306 MainPageBehaviorImpl, 307 MainPageBehaviorImpl,
307 ]; 308 ];
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