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

Unified Diff: ui/webui/resources/cr_elements/cr_scrollable_behavior.js

Issue 2522783003: MD Settings: Fix CrScrollableBehavior (Closed)
Patch Set: Feedback Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/cr_elements/cr_scrollable_behavior.js
diff --git a/ui/webui/resources/cr_elements/cr_scrollable_behavior.js b/ui/webui/resources/cr_elements/cr_scrollable_behavior.js
index 59e1e53dab1b3e5885ebf1fc432df3a1ffc67b28..6278d6d14fa98323946ece90b599f53afbe6d324 100644
--- a/ui/webui/resources/cr_elements/cr_scrollable_behavior.js
+++ b/ui/webui/resources/cr_elements/cr_scrollable_behavior.js
@@ -37,8 +37,11 @@
/** @polymerBehavior */
var CrScrollableBehavior = {
properties: {
- /** @private */
- intervalId_: Number,
+ /** @private {number|null} */
+ intervalId_: {
+ type: Number,
+ value: null
+ }
},
ready: function() {
@@ -56,7 +59,7 @@ var CrScrollableBehavior = {
},
detached: function() {
- if (this.intervalId_)
+ if (this.intervalId_ !== null)
clearInterval(this.intervalId_);
},
@@ -65,10 +68,13 @@ var CrScrollableBehavior = {
* This ensures that the <iron-list> contents of dynamically sized
* containers are resized correctly.
*/
- updateScrollableContents() {
+ updateScrollableContents: function() {
+ if (this.intervalId_ !== null)
+ return; // notifyResize is arelady in progress.
+
let nodeList = this.root.querySelectorAll('[scrollable] iron-list');
- // Use setTimeout to avoid initial render / sizing issues.
- this.intervalId_ = setInterval(function() {
+ // Use setInterval to avoid initial render / sizing issues.
+ this.intervalId_ = window.setInterval(function() {
let unreadyNodes = [];
for (let node of nodeList) {
if (node.parentNode.scrollHeight == 0) {
@@ -78,10 +84,12 @@ var CrScrollableBehavior = {
let ironList = /** @type {!IronListElement} */ (node);
ironList.notifyResize();
}
- if (unreadyNodes.length == 0)
- clearInterval(this.intervalId_);
- else
+ if (unreadyNodes.length == 0) {
+ window.clearInterval(this.intervalId_);
+ this.intervalId_ = null;
+ } else {
nodeList = unreadyNodes;
+ }
}.bind(this), 10);
},
@@ -90,7 +98,7 @@ var CrScrollableBehavior = {
* @param {!Event} event
* @private
*/
- updateScrollEvent_(event) {
+ updateScrollEvent_: function(event) {
let scrollable = /** @type {!HTMLElement} */ (event.target);
this.updateScroll_(scrollable);
},
@@ -100,7 +108,7 @@ var CrScrollableBehavior = {
* @param {!HTMLElement} scrollable
* @private
*/
- updateScroll_(scrollable) {
+ updateScroll_: function(scrollable) {
scrollable.classList.toggle(
'can-scroll', scrollable.clientHeight < scrollable.scrollHeight);
scrollable.classList.toggle('is-scrolled', scrollable.scrollTop > 0);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698