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

Unified Diff: third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js

Issue 2074813002: Roll Polymer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: chromium.patch Created 4 years, 6 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: third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js
index 7430072cd31ac3e34ac13cd5c2401b6a56804fc3..4d55a0ce9d769c7f9f6b297492ea2a8c151ba462 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js
@@ -155,7 +155,7 @@
_physicalSize: 0,
/**
- * The average `F` of the tiles observed till now.
+ * The average `offsetHeight` of the tiles observed till now.
*/
_physicalAverage: 0,
@@ -423,7 +423,6 @@
if (physicalOffset > this._scrollPosition) {
return this.grid ? vidx - (vidx % this._itemsPerRow) : vidx;
}
-
// Handle a partially rendered final row in grid mode
if (this.grid && this._virtualCount - 1 === vidx) {
return vidx - (vidx % this._itemsPerRow);
@@ -442,21 +441,17 @@
if (this._lastVisibleIndexVal === null) {
if (this.grid) {
var lastIndex = this.firstVisibleIndex + this._estRowsInView * this._itemsPerRow - 1;
- this._lastVisibleIndexVal = lastIndex > this._virtualCount ? this._virtualCount : lastIndex;
+ this._lastVisibleIndexVal = Math.min(this._virtualCount, lastIndex);
} else {
var physicalOffset = this._physicalTop;
-
this._iterateItems(function(pidx, vidx) {
- physicalOffset += this._getPhysicalSizeIncrement(pidx);
-
- if(physicalOffset <= this._scrollBottom) {
- if (this.grid) {
- var lastIndex = vidx - vidx % this._itemsPerRow + this._itemsPerRow - 1;
- this._lastVisibleIndexVal = lastIndex > this._virtualCount ? this._virtualCount : lastIndex;
- } else {
- this._lastVisibleIndexVal = vidx;
- }
+ if (physicalOffset < this._scrollBottom) {
+ this._lastVisibleIndexVal = vidx;
+ } else {
+ // Break _iterateItems
+ return true;
}
+ physicalOffset += this._getPhysicalSizeIncrement(pidx);
});
}
}
@@ -831,31 +826,24 @@
if (!this._physicalIndexForKey) {
return;
}
- var inst;
var dot = path.indexOf('.');
var key = path.substring(0, dot < 0 ? path.length : dot);
var idx = this._physicalIndexForKey[key];
- var el = this._physicalItems[idx];
-
-
- if (idx === this._focusedIndex && this._offscreenFocusedItem) {
- el = this._offscreenFocusedItem;
- }
- if (!el) {
- return;
- }
-
- inst = el._templateInstance;
+ var offscreenItem = this._offscreenFocusedItem;
+ var el = offscreenItem && offscreenItem._templateInstance.__key__ === key ?
+ offscreenItem : this._physicalItems[idx];
- if (inst.__key__ !== key) {
+ if (!el || el._templateInstance.__key__ !== key) {
return;
}
+
if (dot >= 0) {
path = this.as + '.' + path.substring(dot+1);
- inst.notifyPath(path, value, true);
+ el._templateInstance.notifyPath(path, value, true);
} else {
- inst[this.as] = value;
+ el._templateInstance[this.as] = value;
}
+
},
/**
@@ -870,10 +858,11 @@
this._virtualCount = this.items ? this.items.length : 0;
this._collection = this.items ? Polymer.Collection.get(this.items) : null;
this._physicalIndexForKey = {};
+ this._firstVisibleIndexVal = null;
+ this._lastVisibleIndexVal = null;
this._resetScrollPosition(0);
this._removeFocusedItem();
-
// create the initial physical items
if (!this._physicalItems) {
this._physicalCount = Math.max(1, Math.min(DEFAULT_PHYSICAL_COUNT, this._virtualCount));
@@ -884,6 +873,7 @@
this._physicalStart = 0;
} else if (change.path === 'items.splices') {
+
this._adjustVirtualIndex(change.value.indexSplices);
this._virtualCount = this.items ? this.items.length : 0;
@@ -1116,7 +1106,7 @@
if (deltaHeight) {
this._physicalTop = this._physicalTop - deltaHeight;
// juking scroll position during interial scrolling on iOS is no bueno
- if (!IOS_TOUCH_SCROLLING) {
+ if (!IOS_TOUCH_SCROLLING && this._physicalTop !== 0) {
this._resetScrollPosition(this._scrollTop - deltaHeight);
}
}
@@ -1155,15 +1145,27 @@
this._scrollHeight = this._estScrollHeight;
}
},
+
/**
* Scroll to a specific item in the virtual list regardless
* of the physical items in the DOM tree.
*
+ * @method scrollToItem
+ * @param {(Object)} item The item to be scrolled to
+ */
+ scrollToItem: function(item){
+ return this.scrollToIndex(this.items.indexOf(item));
+ },
+
+ /**
+ * Scroll to a specific index in the virtual list regardless
+ * of the physical items in the DOM tree.
+ *
* @method scrollToIndex
* @param {number} idx The index of the item
*/
scrollToIndex: function(idx) {
- if (typeof idx !== 'number') {
+ if (typeof idx !== 'number' || idx < 0 || idx > this.items.length - 1) {
return;
}

Powered by Google App Engine
This is Rietveld 408576698