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

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

Issue 2840313002: MD Settings: user list fixes (Closed)
Patch Set: Fix closure Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/closure_compiler/externs/users_private.js ('k') | 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 6e5dd3d28e98336c346a21a1f47051c47d298e8d..38eb1777fcf1e3f10af156893e37f1077c1f0bde 100644
--- a/ui/webui/resources/cr_elements/cr_scrollable_behavior.js
+++ b/ui/webui/resources/cr_elements/cr_scrollable_behavior.js
@@ -41,15 +41,10 @@ var CrScrollableBehavior = {
intervalId_: null,
ready: function() {
- var scrollableElements = this.root.querySelectorAll('[scrollable]');
-
- // Setup the intial scrolling related classes for each scrollable container.
- requestAnimationFrame(function() {
- for (var i = 0; i < scrollableElements.length; i++)
- this.updateScroll_(scrollableElements[i]);
- }.bind(this));
+ this.requestUpdateScroll();
// Listen to the 'scroll' event for each scrollable container.
+ var scrollableElements = this.root.querySelectorAll('[scrollable]');
for (var i = 0; i < scrollableElements.length; i++) {
scrollableElements[i].addEventListener(
'scroll', this.updateScrollEvent_.bind(this));
@@ -70,7 +65,12 @@ var CrScrollableBehavior = {
if (this.intervalId_ !== null)
return; // notifyResize is arelady in progress.
+ this.requestUpdateScroll();
+
var nodeList = this.root.querySelectorAll('[scrollable] iron-list');
+ if (!nodeList.length)
+ return;
+
// Use setInterval to avoid initial render / sizing issues.
this.intervalId_ = window.setInterval(function() {
var unreadyNodes = [];
@@ -92,6 +92,19 @@ var CrScrollableBehavior = {
}.bind(this), 10);
},
+ /**
+ * Setup the intial scrolling related classes for each scrollable container.
+ * Called from ready() and updateScrollableContents(). May also be called
+ * directly when the contents change (e.g. when not using iron-list).
+ */
+ requestUpdateScroll: function() {
+ requestAnimationFrame(function() {
+ var scrollableElements = this.root.querySelectorAll('[scrollable]');
+ for (var i = 0; i < scrollableElements.length; i++)
+ this.updateScroll_(/** @type {!HTMLElement} */(scrollableElements[i]));
+ }.bind(this));
+ },
+
/** @param {!IronListElement} list */
saveScroll: function(list) {
// Store a FIFO of saved scroll positions so that multiple updates in a
« no previous file with comments | « third_party/closure_compiler/externs/users_private.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698