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

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

Issue 2867053003: MD-Settings - Update iron-list to fix scroll issue. (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 (function() { 1 (function() {
2 2
3 var IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/); 3 var IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);
4 var IOS_TOUCH_SCROLLING = IOS && IOS[1] >= 8; 4 var IOS_TOUCH_SCROLLING = IOS && IOS[1] >= 8;
5 var DEFAULT_PHYSICAL_COUNT = 3; 5 var DEFAULT_PHYSICAL_COUNT = 3;
6 var HIDDEN_Y = '-10000px'; 6 var HIDDEN_Y = '-10000px';
7 var ITEM_WIDTH = 0; 7 var ITEM_WIDTH = 0;
8 var ITEM_HEIGHT = 1; 8 var ITEM_HEIGHT = 1;
9 var SECRET_TABINDEX = -100; 9 var SECRET_TABINDEX = -100;
10 10
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 var scrollTop = Math.max(0, Math.min(this._maxScrollTop, this._scrollTop)) ; 551 var scrollTop = Math.max(0, Math.min(this._maxScrollTop, this._scrollTop)) ;
552 var delta = scrollTop - this._scrollPosition; 552 var delta = scrollTop - this._scrollPosition;
553 var isScrollingDown = delta >= 0; 553 var isScrollingDown = delta >= 0;
554 // Track the current scroll position. 554 // Track the current scroll position.
555 this._scrollPosition = scrollTop; 555 this._scrollPosition = scrollTop;
556 // Clear indexes. 556 // Clear indexes.
557 this._firstVisibleIndexVal = null; 557 this._firstVisibleIndexVal = null;
558 this._lastVisibleIndexVal = null; 558 this._lastVisibleIndexVal = null;
559 559
560 // Random access. 560 // Random access.
561 if (Math.abs(delta) > this._physicalSize) { 561 if (Math.abs(delta) > this._physicalSize && this._physicalSize > 0) {
562 delta = delta - this._scrollOffset; 562 delta = delta - this._scrollOffset;
563 var idxAdjustment = Math.round(delta / this._physicalAverage) * this._it emsPerRow; 563 var idxAdjustment = Math.round(delta / this._physicalAverage) * this._it emsPerRow;
564 this._physicalTop = this._physicalTop + delta;
565 this._virtualStart = this._virtualStart + idxAdjustment; 564 this._virtualStart = this._virtualStart + idxAdjustment;
566 this._physicalStart = this._physicalStart + idxAdjustment; 565 this._physicalStart = this._physicalStart + idxAdjustment;
566 // Estimate new physical offset.
567 this._physicalTop = Math.floor(this._virtualStart / this._itemsPerRow) * this._physicalAverage;
567 this._update(); 568 this._update();
568 } else { 569 } else {
569 var reusables = this._getReusables(isScrollingDown); 570 var reusables = this._getReusables(isScrollingDown);
570 if (isScrollingDown) { 571 if (isScrollingDown) {
571 this._physicalTop = reusables.physicalTop; 572 this._physicalTop = reusables.physicalTop;
572 this._virtualStart = this._virtualStart + reusables.indexes.length; 573 this._virtualStart = this._virtualStart + reusables.indexes.length;
573 this._physicalStart = this._physicalStart + reusables.indexes.length; 574 this._physicalStart = this._physicalStart + reusables.indexes.length;
574 } else { 575 } else {
575 this._virtualStart = this._virtualStart - reusables.indexes.length; 576 this._virtualStart = this._virtualStart - reusables.indexes.length;
576 this._physicalStart = this._physicalStart - reusables.indexes.length; 577 this._physicalStart = this._physicalStart - reusables.indexes.length;
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 this._assignModels(); 1537 this._assignModels();
1537 // Get the new physical index for the focused index. 1538 // Get the new physical index for the focused index.
1538 pidx = this._getPhysicalIndex(fidx); 1539 pidx = this._getPhysicalIndex(fidx);
1539 1540
1540 var onScreenItem = this._physicalItems[pidx]; 1541 var onScreenItem = this._physicalItems[pidx];
1541 if (!onScreenItem) { 1542 if (!onScreenItem) {
1542 return; 1543 return;
1543 } 1544 }
1544 var onScreenInstance = onScreenItem._templateInstance; 1545 var onScreenInstance = onScreenItem._templateInstance;
1545 var offScreenInstance = this._offscreenFocusedItem._templateInstance; 1546 var offScreenInstance = this._offscreenFocusedItem._templateInstance;
1546 // Restores the physical item only when it has the same model 1547 // Restores the physical item only when it has the same model
1547 // as the offscreen one. Use key for comparison since users can set 1548 // as the offscreen one. Use key for comparison since users can set
1548 // a new item via set('items.idx'). 1549 // a new item via set('items.idx').
1549 if (onScreenInstance.__key__ === offScreenInstance.__key__) { 1550 if (onScreenInstance.__key__ === offScreenInstance.__key__) {
1550 // Flip the focus backfill. 1551 // Flip the focus backfill.
1551 this._focusBackfillItem = onScreenItem; 1552 this._focusBackfillItem = onScreenItem;
1552 onScreenInstance.tabIndex = -1; 1553 onScreenInstance.tabIndex = -1;
1553 // Restore the focused physical item. 1554 // Restore the focused physical item.
1554 this._physicalItems[pidx] = this._offscreenFocusedItem; 1555 this._physicalItems[pidx] = this._offscreenFocusedItem;
1555 // Hide the physical item that backfills. 1556 // Hide the physical item that backfills.
1556 this.translate3d(0, HIDDEN_Y, 0, this._focusBackfillItem); 1557 this.translate3d(0, HIDDEN_Y, 0, this._focusBackfillItem);
1557 } else { 1558 } else {
1559 this._removeFocusedItem();
1558 this._focusBackfillItem = null; 1560 this._focusBackfillItem = null;
1559 } 1561 }
1560 this._offscreenFocusedItem = null; 1562 this._offscreenFocusedItem = null;
1561 }, 1563 },
1562 1564
1563 _didFocus: function(e) { 1565 _didFocus: function(e) {
1564 var targetModel = this.modelForElement(e.target); 1566 var targetModel = this.modelForElement(e.target);
1565 var focusedModel = this._focusedItem ? this._focusedItem._templateInstance : null; 1567 var focusedModel = this._focusedItem ? this._focusedItem._templateInstance : null;
1566 var hasOffscreenFocusedItem = this._offscreenFocusedItem !== null; 1568 var hasOffscreenFocusedItem = this._offscreenFocusedItem !== null;
1567 var fidx = this._focusedIndex; 1569 var fidx = this._focusedIndex;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 this._focusPhysicalItem(this._focusedIndex + 1); 1601 this._focusPhysicalItem(this._focusedIndex + 1);
1600 }, 1602 },
1601 1603
1602 _didEnter: function(e) { 1604 _didEnter: function(e) {
1603 this._focusPhysicalItem(this._focusedIndex); 1605 this._focusPhysicalItem(this._focusedIndex);
1604 this._selectionHandler(e.detail.keyboardEvent); 1606 this._selectionHandler(e.detail.keyboardEvent);
1605 } 1607 }
1606 }); 1608 });
1607 1609
1608 })(); 1610 })();
OLDNEW
« no previous file with comments | « third_party/polymer/v1_0/components-chromium/iron-list/bower.json ('k') | third_party/polymer/v1_0/components_summary.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698