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

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

Issue 2552393002: MD Settings: Scroll correctly for navigations that exit search mode. (Closed)
Patch Set: update 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
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 */
11 var MainPageBehaviorImpl = { 11 var MainPageBehaviorImpl = {
12 properties: {
13 /**
14 * Whether a search operation is in progress or previous search results are
15 * being displayed.
16 * @private {boolean}
17 */
18 inSearchMode: {
19 type: Boolean,
20 value: false,
21 observer: 'inSearchModeChanged_',
22 },
23 },
24
12 /** @type {?HTMLElement} The scrolling container. */ 25 /** @type {?HTMLElement} The scrolling container. */
13 scroller: null, 26 scroller: null,
14 27
15 /** @override */ 28 /** @override */
16 attached: function() { 29 attached: function() {
17 if (this.domHost && this.domHost.parentNode.tagName == 'PAPER-HEADER-PANEL') 30 if (this.domHost && this.domHost.parentNode.tagName == 'PAPER-HEADER-PANEL')
18 this.scroller = this.domHost.parentNode.scroller; 31 this.scroller = this.domHost.parentNode.scroller;
19 else 32 else
20 this.scroller = document.body; // Used in unit tests. 33 this.scroller = document.body; // Used in unit tests.
21 }, 34 },
(...skipping 19 matching lines...) Expand all
41 54
42 // For previously uncreated pages (including on first load), allow the page 55 // For previously uncreated pages (including on first load), allow the page
43 // to render before scrolling to or expanding the section. 56 // to render before scrolling to or expanding the section.
44 if (!oldRoute || this.scrollHeight == 0) 57 if (!oldRoute || this.scrollHeight == 0)
45 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); 58 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection));
46 else 59 else
47 this.tryTransitionToSection_(scrollToSection); 60 this.tryTransitionToSection_(scrollToSection);
48 }, 61 },
49 62
50 /** 63 /**
64 * When exiting search mode, we need to make another attempt to scroll to
65 * the correct section, since it has just been re-rendered.
66 * @private
67 */
68 inSearchModeChanged_: function(inSearchMode) {
69 if (!inSearchMode)
70 this.tryTransitionToSection_(!settings.lastRouteChangeWasPopstate());
71 },
72
73 /**
51 * If possible, transitions to the current route's section (by expanding or 74 * If possible, transitions to the current route's section (by expanding or
52 * scrolling to it). If another transition is running, finishes or cancels 75 * scrolling to it). If another transition is running, finishes or cancels
53 * that one, then schedules this function again. This ensures the current 76 * that one, then schedules this function again. This ensures the current
54 * section is quickly shown, without getting the page into a broken state -- 77 * section is quickly shown, without getting the page into a broken state --
55 * if currentRoute changes in between calls, just transition to the new route. 78 * if currentRoute changes in between calls, just transition to the new route.
56 * @param {boolean} scrollToSection 79 * @param {boolean} scrollToSection
57 * @private 80 * @private
58 */ 81 */
59 tryTransitionToSection_: function(scrollToSection) { 82 tryTransitionToSection_: function(scrollToSection) {
60 var currentRoute = settings.getCurrentRoute(); 83 var currentRoute = settings.getCurrentRoute();
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 return /** @type {?SettingsSectionElement} */( 295 return /** @type {?SettingsSectionElement} */(
273 this.$$('settings-section[section="' + section + '"]')); 296 this.$$('settings-section[section="' + section + '"]'));
274 }, 297 },
275 }; 298 };
276 299
277 /** @polymerBehavior */ 300 /** @polymerBehavior */
278 var MainPageBehavior = [ 301 var MainPageBehavior = [
279 settings.RouteObserverBehavior, 302 settings.RouteObserverBehavior,
280 MainPageBehaviorImpl, 303 MainPageBehaviorImpl,
281 ]; 304 ];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698