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

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

Issue 2522783003: MD Settings: Fix CrScrollableBehavior (Closed)
Patch Set: Fix logic and use null 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..c5e52e7b2e621595a4da47ff2ddc285c417de0df 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_);
},
@@ -67,8 +70,10 @@ var CrScrollableBehavior = {
*/
updateScrollableContents() {
dpapad 2016/11/23 18:30:21 updateScrollableContents: function() {
stevenjb 2016/11/23 18:37:15 Sigh. Still a C++ developer at heart. Done.
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.
+ if (this.intervalId_ !== null)
dpapad 2016/11/23 18:30:21 Can you move this before the querySelectorAll? So
stevenjb 2016/11/23 18:37:15 Good catch. Done.
+ return;
+ this.intervalId_ = window.setInterval(function() {
let unreadyNodes = [];
for (let node of nodeList) {
if (node.parentNode.scrollHeight == 0) {
@@ -78,10 +83,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);
},
« 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