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

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

Issue 2758863004: [MD settings] hide scrollbar during animation to subpage (Closed)
Patch Set: comment nit Created 3 years, 9 months 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 | « chrome/browser/resources/settings/basic_page/basic_page.html ('k') | no next file » | 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 */
11 var MainPageBehaviorImpl = { 11 var MainPageBehaviorImpl = {
12 properties: { 12 properties: {
13 /** 13 /**
14 * Help CSS to alter style during the horizontal swipe animation.
15 * Note that this is unrelated to the |currentAnimation_| (which refers to
16 * the vertical exapand animation).
17 */
18 isSubpageAnimating: {
19 reflectToAttribute: true,
20 type: Boolean,
21 },
22
23 /**
14 * Whether a search operation is in progress or previous search results are 24 * Whether a search operation is in progress or previous search results are
15 * being displayed. 25 * being displayed.
16 * @private {boolean} 26 * @private {boolean}
17 */ 27 */
18 inSearchMode: { 28 inSearchMode: {
19 type: Boolean, 29 type: Boolean,
20 value: false, 30 value: false,
21 observer: 'inSearchModeChanged_', 31 observer: 'inSearchModeChanged_',
22 }, 32 },
23 }, 33 },
24 34
25 /** @type {?HTMLElement} The scrolling container. */ 35 /** @type {?HTMLElement} The scrolling container. */
26 scroller: null, 36 scroller: null,
27 37
38 listeners: {
39 'neon-animation-finish': 'onNeonAnimationFinish_'
40 },
41
28 /** @override */ 42 /** @override */
29 attached: function() { 43 attached: function() {
30 if (this.domHost && this.domHost.parentNode.tagName == 'PAPER-HEADER-PANEL') 44 if (this.domHost && this.domHost.parentNode.tagName == 'PAPER-HEADER-PANEL')
31 this.scroller = this.domHost.parentNode.scroller; 45 this.scroller = this.domHost.parentNode.scroller;
32 else 46 else
33 this.scroller = document.body; // Used in unit tests. 47 this.scroller = document.body; // Used in unit tests.
34 }, 48 },
35 49
36 /** 50 /**
51 * Remove the is-animating attribute once the animation is complete.
52 * This may catch animations finishing more often than needed, which is not
53 * known to cause any issues (e.g. when animating from a shallower page to a
54 * deeper page; or when transitioning to the main page).
55 * @private
56 */
57 onNeonAnimationFinish_: function() {
58 this.isSubpageAnimating = false;
59 },
60
61 /**
37 * @param {!settings.Route} newRoute 62 * @param {!settings.Route} newRoute
38 * @param {settings.Route} oldRoute 63 * @param {settings.Route} oldRoute
39 */ 64 */
40 currentRouteChanged: function(newRoute, oldRoute) { 65 currentRouteChanged: function(newRoute, oldRoute) {
41 var oldRouteWasSection = 66 var oldRouteWasSection =
42 !!oldRoute && !!oldRoute.parent && !!oldRoute.section && 67 !!oldRoute && !!oldRoute.parent && !!oldRoute.section &&
43 oldRoute.parent.section != oldRoute.section; 68 oldRoute.parent.section != oldRoute.section;
44 69
45 // Always scroll to the top if navigating from a section to the root route 70 // Always scroll to the top if navigating from a section to the root route
46 // or when navigating to the About page. 71 // or when navigating to the About page.
47 if (this.scroller && 72 if (this.scroller &&
48 ((oldRouteWasSection && newRoute == settings.Route.BASIC) || 73 ((oldRouteWasSection && newRoute == settings.Route.BASIC) ||
49 newRoute == settings.Route.ABOUT)) { 74 newRoute == settings.Route.ABOUT)) {
50 this.scroller.scrollTop = 0; 75 this.scroller.scrollTop = 0;
51 return; 76 return;
52 } 77 }
53 78
54 // Scroll to the section except for back/forward. Also scroll for any 79 // Scroll to the section except for back/forward. Also scroll for any
55 // in-page back/forward navigations (from a section or the root page). 80 // in-page back/forward navigations (from a section or the root page).
56 var scrollToSection = 81 var scrollToSection =
57 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection || 82 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection ||
58 oldRoute == settings.Route.BASIC; 83 oldRoute == settings.Route.BASIC;
59 84
85 if (oldRoute && newRoute.isSubpage() && oldRoute.depth > newRoute.depth)
Dan Beam 2017/03/21 07:12:50 i'm still confused. wouldn't we want to handle ch
dschuyler 2017/03/21 18:19:18 To the best of my knowledge an erroneous scroll ba
Dan Beam 2017/03/21 20:39:28 how about name hideOverflow?
dschuyler 2017/03/22 00:58:50 That would work for me :), but it seems to be 'pre
86 this.isSubpageAnimating = true;
87
60 // For previously uncreated pages (including on first load), allow the page 88 // For previously uncreated pages (including on first load), allow the page
61 // to render before scrolling to or expanding the section. 89 // to render before scrolling to or expanding the section.
62 if (!oldRoute || this.scrollHeight == 0) 90 if (!oldRoute || this.scrollHeight == 0)
63 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); 91 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection));
64 else 92 else
65 this.tryTransitionToSection_(scrollToSection); 93 this.tryTransitionToSection_(scrollToSection);
66 }, 94 },
67 95
68 /** 96 /**
69 * When exiting search mode, we need to make another attempt to scroll to 97 * When exiting search mode, we need to make another attempt to scroll to
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 return /** @type {?SettingsSectionElement} */( 332 return /** @type {?SettingsSectionElement} */(
305 this.$$('settings-section[section="' + section + '"]')); 333 this.$$('settings-section[section="' + section + '"]'));
306 }, 334 },
307 }; 335 };
308 336
309 /** @polymerBehavior */ 337 /** @polymerBehavior */
310 var MainPageBehavior = [ 338 var MainPageBehavior = [
311 settings.RouteObserverBehavior, 339 settings.RouteObserverBehavior,
312 MainPageBehaviorImpl, 340 MainPageBehaviorImpl,
313 ]; 341 ];
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/basic_page/basic_page.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698