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

Side by Side Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2206723002: [MD settings] shrink overscroll when scrolling up (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed var name Created 4 years, 4 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/settings_main/settings_main.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 * @fileoverview 6 * @fileoverview
7 * 'settings-main' displays the selected settings page. 7 * 'settings-main' displays the selected settings page.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-main', 10 is: 'settings-main',
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 /** 64 /**
65 * Dictionary defining page visibility. 65 * Dictionary defining page visibility.
66 * @type {!GuestModePageVisibility} 66 * @type {!GuestModePageVisibility}
67 */ 67 */
68 pageVisibility: { 68 pageVisibility: {
69 type: Object, 69 type: Object,
70 value: function() { return {}; }, 70 value: function() { return {}; },
71 }, 71 },
72 }, 72 },
73 73
74 /**
75 * The smallest value for the height of the overscroll padding.
76 * @const {number}
77 */
78 MINIMUM_OVERSCROLL: 64,
Dan Beam 2016/08/02 21:57:36 can you make this private?
dschuyler 2016/08/02 22:32:44 Done. And then ended up removing it.
79
74 /** @override */ 80 /** @override */
75 attached: function() { 81 attached: function() {
76 document.addEventListener('toggle-advanced-page', function(e) { 82 document.addEventListener('toggle-advanced-page', function(e) {
77 this.advancedToggleExpanded_ = e.detail; 83 this.advancedToggleExpanded_ = e.detail;
78 settings.navigateTo(this.advancedToggleExpanded_ ? 84 settings.navigateTo(this.advancedToggleExpanded_ ?
79 settings.Route.ADVANCED : settings.Route.BASIC); 85 settings.Route.ADVANCED : settings.Route.BASIC);
80 }.bind(this)); 86 }.bind(this));
87
88 var mainContainer = this.domHost.$$('paper-header-panel').$.mainContainer;
89 mainContainer.addEventListener('scroll', function() {
90 let visibleBottom = mainContainer.scrollTop + mainContainer.clientHeight;
91 let overscrollBottom = this.$.overscroll.offsetTop +
Dan Beam 2016/08/02 21:57:36 nit: var overscroll = this.$.overscroll; (and re-u
dschuyler 2016/08/02 22:32:44 Done.
92 this.$.overscroll.scrollHeight;
93 // How much of the overscroll is visible (may be negative).
94 let visibleOverscroll = this.$.overscroll.scrollHeight -
95 (overscrollBottom - visibleBottom);
Dan Beam 2016/08/02 21:57:36 indent off
dschuyler 2016/08/02 22:32:44 Done.
96 if (visibleOverscroll > this.MINIMUM_OVERSCROLL)
97 this.$.overscroll.style.paddingBottom = visibleOverscroll + 'px';
98 }.bind(this));
81 }, 99 },
82 100
83 /** 101 /**
84 * @param {boolean} opened Whether the menu is expanded. 102 * @param {boolean} opened Whether the menu is expanded.
85 * @return {string} Which icon to use. 103 * @return {string} Which icon to use.
86 * @private 104 * @private
87 */ 105 */
88 arrowState_: function(opened) { 106 arrowState_: function(opened) {
89 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; 107 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down';
90 }, 108 },
(...skipping 30 matching lines...) Expand all
121 this.pageVisibility.advancedSettings !== false); 139 this.pageVisibility.advancedSettings !== false);
122 this.advancedToggleExpanded_ = true; 140 this.advancedToggleExpanded_ = true;
123 } 141 }
124 } 142 }
125 143
126 // Wait for any other changes prior to calculating the overflow padding. 144 // Wait for any other changes prior to calculating the overflow padding.
127 setTimeout(function() { 145 setTimeout(function() {
128 // Ensure any dom-if reflects the current properties. 146 // Ensure any dom-if reflects the current properties.
129 Polymer.dom.flush(); 147 Polymer.dom.flush();
130 148
131 this.$.overscroll.style.paddingBottom = this.overscrollHeight_() + 'px'; 149 this.$.overscroll.style.paddingBottom = Math.max(this.MINIMUM_OVERSCROLL,
150 this.overscrollHeight_()) + 'px';
132 }.bind(this)); 151 }.bind(this));
133 }, 152 },
134 153
135 /** 154 /**
136 * Return the height that the overscroll padding should be set to. 155 * Return the height that the overscroll padding should be set to.
137 * This is used to determine how much padding to apply to the end of the 156 * This is used to determine how much padding to apply to the end of the
138 * content so that the last element may align with the top of the content 157 * content so that the last element may align with the top of the content
139 * area. 158 * area.
140 * @return {number} 159 * @return {number}
141 * @private 160 * @private
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 227
209 /** 228 /**
210 * @param {(boolean|undefined)} visibility 229 * @param {(boolean|undefined)} visibility
211 * @return {boolean} True unless visibility is false. 230 * @return {boolean} True unless visibility is false.
212 * @private 231 * @private
213 */ 232 */
214 showAdvancedSettings_: function(visibility) { 233 showAdvancedSettings_: function(visibility) {
215 return visibility !== false; 234 return visibility !== false;
216 }, 235 },
217 }); 236 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/settings_main/settings_main.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698