Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 /** @private */ | 31 /** @private */ |
| 32 advancedToggleExpanded_: { | 32 advancedToggleExpanded_: { |
| 33 type: Boolean, | 33 type: Boolean, |
| 34 value: false, | 34 value: false, |
| 35 }, | 35 }, |
| 36 | 36 |
| 37 /** @private */ | 37 /** @private */ |
| 38 inSubpage_: Boolean, | 38 inSubpage_: Boolean, |
| 39 | 39 |
| 40 /** @private */ | |
| 41 overscroll_: { | |
| 42 type: Number, | |
| 43 observer: 'overscrollChanged_', | |
| 44 }, | |
| 45 | |
| 40 /** | 46 /** |
| 41 * Controls which main pages are displayed via dom-ifs. | 47 * Controls which main pages are displayed via dom-ifs. |
| 42 * @type {!{about: boolean, basic: boolean, advanced: boolean}} | 48 * @type {!{about: boolean, basic: boolean, advanced: boolean}} |
| 43 * @private | 49 * @private |
| 44 */ | 50 */ |
| 45 showPages_: { | 51 showPages_: { |
| 46 type: Object, | 52 type: Object, |
| 47 value: function() { | 53 value: function() { |
| 48 return {about: false, basic: false, advanced: false}; | 54 return {about: false, basic: false, advanced: false}; |
| 49 }, | 55 }, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 71 }, | 77 }, |
| 72 }, | 78 }, |
| 73 | 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 }, | |
| 89 | |
| 90 /** @private */ | |
| 91 overscrollChanged_: function() { | |
| 92 if (!this.overscroll_ && this.boundScroll_) { | |
| 93 this.parentNode.scroller.removeEventListener('scroll', this.boundScroll_); | |
| 94 this.boundScroll_ = null; | |
| 95 } else if (this.overscroll_ && !this.boundScroll_) { | |
| 96 this.boundScroll_ = this.scrollEventListener_.bind(this); | |
| 97 this.parentNode.scroller.addEventListener('scroll', this.boundScroll_); | |
| 98 } | |
| 99 }, | |
| 100 | |
| 101 /** @private */ | |
| 102 scrollEventListener_: function() { | |
| 103 var scroller = this.parentNode.scroller; | |
| 104 var overscroll = this.$.overscroll; | |
| 105 var visibleBottom = scroller.scrollTop + scroller.clientHeight; | |
| 106 var overscrollBottom = overscroll.offsetTop + overscroll.scrollHeight; | |
| 107 // How much of the overscroll is visible (may be negative). | |
| 108 var visibleOverscroll = overscroll.scrollHeight - | |
| 109 (overscrollBottom - visibleBottom); | |
| 110 this.overscroll_ = Math.max(0, visibleOverscroll); | |
|
Dan Beam
2016/08/03 22:04:59
if this could share more with overscrollHeight_ th
dschuyler
2016/08/03 22:26:03
I think the math looks similar off the cuff. I don
| |
| 81 }, | 111 }, |
| 82 | 112 |
| 83 /** | 113 /** |
| 84 * @param {boolean} opened Whether the menu is expanded. | 114 * @param {boolean} opened Whether the menu is expanded. |
| 85 * @return {string} Which icon to use. | 115 * @return {string} Which icon to use. |
| 86 * @private | 116 * @private |
| 87 */ | 117 */ |
| 88 arrowState_: function(opened) { | 118 arrowState_: function(opened) { |
| 89 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; | 119 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; |
| 90 }, | 120 }, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 121 this.pageVisibility.advancedSettings !== false); | 151 this.pageVisibility.advancedSettings !== false); |
| 122 this.advancedToggleExpanded_ = true; | 152 this.advancedToggleExpanded_ = true; |
| 123 } | 153 } |
| 124 } | 154 } |
| 125 | 155 |
| 126 // Wait for any other changes prior to calculating the overflow padding. | 156 // Wait for any other changes prior to calculating the overflow padding. |
| 127 setTimeout(function() { | 157 setTimeout(function() { |
| 128 // Ensure any dom-if reflects the current properties. | 158 // Ensure any dom-if reflects the current properties. |
| 129 Polymer.dom.flush(); | 159 Polymer.dom.flush(); |
| 130 | 160 |
| 131 this.$.overscroll.style.paddingBottom = this.overscrollHeight_() + 'px'; | 161 this.overscroll_ = this.overscrollHeight_(); |
| 132 }.bind(this)); | 162 }.bind(this)); |
| 133 }, | 163 }, |
| 134 | 164 |
| 135 /** | 165 /** |
| 136 * Return the height that the overscroll padding should be set to. | 166 * 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 | 167 * 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 | 168 * content so that the last element may align with the top of the content |
| 139 * area. | 169 * area. |
| 140 * @return {number} | 170 * @return {number} |
| 141 * @private | 171 * @private |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 | 243 |
| 214 /** | 244 /** |
| 215 * @param {(boolean|undefined)} visibility | 245 * @param {(boolean|undefined)} visibility |
| 216 * @return {boolean} True unless visibility is false. | 246 * @return {boolean} True unless visibility is false. |
| 217 * @private | 247 * @private |
| 218 */ | 248 */ |
| 219 showAdvancedSettings_: function(visibility) { | 249 showAdvancedSettings_: function(visibility) { |
| 220 return visibility !== false; | 250 return visibility !== false; |
| 221 }, | 251 }, |
| 222 }); | 252 }); |
| OLD | NEW |