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/network/cr_network_list.js

Issue 2627373002: MD Settings: Save and restore scroll position in iron-list (Closed)
Patch Set: Use scrollTop Created 3 years, 11 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
Index: ui/webui/resources/cr_elements/network/cr_network_list.js
diff --git a/ui/webui/resources/cr_elements/network/cr_network_list.js b/ui/webui/resources/cr_elements/network/cr_network_list.js
index e5de1abd3501f99ab432c7151d2f92b8cd823817..571661753f819bac82932c3d9fcb6e176b15063a 100644
--- a/ui/webui/resources/cr_elements/network/cr_network_list.js
+++ b/ui/webui/resources/cr_elements/network/cr_network_list.js
@@ -49,29 +49,36 @@ Polymer({
selectedItem: {
type: Object,
observer: 'selectedItemChanged_',
- }
+ },
+
+ /**
+ * Contains |networks| + |customItems|.
+ * @private {!Array<!CrNetworkList.CrNetworkListItemType>}
+ */
+ listItems_: {
+ type: Array,
+ value: function() {
+ return [];
+ }
+ },
},
behaviors: [CrScrollableBehavior],
- observers: ['listChanged_(networks, customItems)'],
+ observers: ['updateListItems_(networks, customItems)'],
/** @private */
- listChanged_: function() {
- this.updateScrollableContents();
- },
+ updateListItems_: function() {
+ var list = this.$.list;
+ this.saveScroll(list);
- /**
- * Returns a combined list of networks and custom items.
- * @return {!Array<!CrNetworkList.CrNetworkListItemType>}
- * @private
- */
- getItems_: function() {
- let customItems = this.customItems.slice();
- // Flag the first custom item with isFirstCustomItem = true.
+ var customItems = this.customItems.slice();
if (customItems.length > 0)
customItems[0].isFirstCustomItem = true;
- return this.networks.concat(customItems);
+ this.listItems_ = this.networks.concat(customItems);
+
+ this.restoreScroll(list);
+ this.updateScrollableContents();
},
/**

Powered by Google App Engine
This is Rietveld 408576698