| 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 * @typedef {{about: boolean, basic: boolean, advanced: boolean}} | 6 * @typedef {{about: boolean, basic: boolean, advanced: boolean}} |
| 7 */ | 7 */ |
| 8 var MainPageVisibility; | 8 var MainPageVisibility; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 * @type {!GuestModePageVisibility} | 83 * @type {!GuestModePageVisibility} |
| 84 */ | 84 */ |
| 85 pageVisibility: { | 85 pageVisibility: { |
| 86 type: Object, | 86 type: Object, |
| 87 value: function() { return {}; }, | 87 value: function() { return {}; }, |
| 88 }, | 88 }, |
| 89 }, | 89 }, |
| 90 | 90 |
| 91 /** @override */ | 91 /** @override */ |
| 92 attached: function() { | 92 attached: function() { |
| 93 this.listen(this, 'freeze-scroll', 'onFreezeScroll_'); |
| 93 var currentRoute = settings.getCurrentRoute(); | 94 var currentRoute = settings.getCurrentRoute(); |
| 94 this.hasExpandedSection_ = currentRoute && currentRoute.isSubpage(); | 95 this.hasExpandedSection_ = currentRoute && currentRoute.isSubpage(); |
| 95 }, | 96 }, |
| 96 | 97 |
| 98 /** @override */ |
| 99 detached: function() { |
| 100 this.unlisten(this, 'freeze-scroll', 'onFreezeScroll_'); |
| 101 }, |
| 102 |
| 97 /** @private */ | 103 /** @private */ |
| 98 overscrollChanged_: function() { | 104 overscrollChanged_: function() { |
| 99 if (!this.overscroll_ && this.boundScroll_) { | 105 if (!this.overscroll_ && this.boundScroll_) { |
| 100 this.offsetParent.removeEventListener('scroll', this.boundScroll_); | 106 this.offsetParent.removeEventListener('scroll', this.boundScroll_); |
| 101 window.removeEventListener('resize', this.boundScroll_); | 107 window.removeEventListener('resize', this.boundScroll_); |
| 102 this.boundScroll_ = null; | 108 this.boundScroll_ = null; |
| 103 } else if (this.overscroll_ && !this.boundScroll_) { | 109 } else if (this.overscroll_ && !this.boundScroll_) { |
| 104 this.boundScroll_ = function() { | 110 this.boundScroll_ = function() { |
| 105 if (!this.ignoreScroll_) | 111 if (!this.ignoreScroll_) |
| 106 this.setOverscroll_(0); | 112 this.setOverscroll_(0); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 126 // How much of the overscroll is visible (may be negative). | 132 // How much of the overscroll is visible (may be negative). |
| 127 var visibleOverscroll = overscroll.scrollHeight - | 133 var visibleOverscroll = overscroll.scrollHeight - |
| 128 (overscrollBottom - visibleBottom); | 134 (overscrollBottom - visibleBottom); |
| 129 this.overscroll_ = Math.max(opt_minHeight || 0, visibleOverscroll); | 135 this.overscroll_ = Math.max(opt_minHeight || 0, visibleOverscroll); |
| 130 }, | 136 }, |
| 131 | 137 |
| 132 /** | 138 /** |
| 133 * Enables or disables user scrolling, via overscroll: hidden. Room for the | 139 * Enables or disables user scrolling, via overscroll: hidden. Room for the |
| 134 * hidden scrollbar is added to prevent the page width from changing back and | 140 * hidden scrollbar is added to prevent the page width from changing back and |
| 135 * forth. Also freezes the overscroll height. | 141 * forth. Also freezes the overscroll height. |
| 136 * @param {!Event} e | 142 * @param {!Event} e |e.detail| is true to freeze, false to unfreeze. |
| 137 * @param {boolean} detail True to freeze, false to unfreeze. | |
| 138 * @private | 143 * @private |
| 139 */ | 144 */ |
| 140 onFreezeScroll_: function(e, detail) { | 145 onFreezeScroll_: function(e) { |
| 141 if (detail) { | 146 if (e.detail) { |
| 142 // Update the overscroll and ignore scroll events. | 147 // Update the overscroll and ignore scroll events. |
| 143 this.setOverscroll_(this.overscrollHeight_()); | 148 this.setOverscroll_(this.overscrollHeight_()); |
| 144 this.ignoreScroll_ = true; | 149 this.ignoreScroll_ = true; |
| 145 | 150 |
| 146 // Prevent scrolling the container. | 151 // Prevent scrolling the container. |
| 147 var scrollerWidth = this.offsetParent.clientWidth; | 152 var scrollerWidth = this.offsetParent.clientWidth; |
| 148 this.offsetParent.style.overflow = 'hidden'; | 153 this.offsetParent.style.overflow = 'hidden'; |
| 149 var scrollbarWidth = this.offsetParent.clientWidth - scrollerWidth; | 154 var scrollbarWidth = this.offsetParent.clientWidth - scrollerWidth; |
| 150 this.offsetParent.style.width = 'calc(100% - ' + scrollbarWidth + 'px)'; | 155 this.offsetParent.style.width = 'calc(100% - ' + scrollbarWidth + 'px)'; |
| 151 } else { | 156 } else { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 355 |
| 351 /** | 356 /** |
| 352 * @param {(boolean|undefined)} visibility | 357 * @param {(boolean|undefined)} visibility |
| 353 * @return {boolean} True unless visibility is false. | 358 * @return {boolean} True unless visibility is false. |
| 354 * @private | 359 * @private |
| 355 */ | 360 */ |
| 356 showAdvancedSettings_: function(visibility) { | 361 showAdvancedSettings_: function(visibility) { |
| 357 return visibility !== false; | 362 return visibility !== false; |
| 358 }, | 363 }, |
| 359 }); | 364 }); |
| OLD | NEW |