| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 _onScroll: function(event) | 578 _onScroll: function(event) |
| 579 { | 579 { |
| 580 this.refresh(); | 580 this.refresh(); |
| 581 }, | 581 }, |
| 582 | 582 |
| 583 /** | 583 /** |
| 584 * @return {number} | 584 * @return {number} |
| 585 */ | 585 */ |
| 586 firstVisibleIndex: function() | 586 firstVisibleIndex: function() |
| 587 { | 587 { |
| 588 var firstVisibleIndex; | 588 var firstVisibleIndex = Math.max(Array.prototype.lowerBound.call(this._c
umulativeHeights, this.element.scrollTop + 1), 0); |
| 589 if (this._stickToBottom) | |
| 590 firstVisibleIndex = Math.max(this._itemCount - Math.ceil(this._visib
leHeight() / this._provider.minimumRowHeight()), 0); | |
| 591 else | |
| 592 firstVisibleIndex = Math.max(Array.prototype.lowerBound.call(this._c
umulativeHeights, this.element.scrollTop + 1), 0); | |
| 593 return Math.max(firstVisibleIndex, this._firstActiveIndex); | 589 return Math.max(firstVisibleIndex, this._firstActiveIndex); |
| 594 }, | 590 }, |
| 595 | 591 |
| 596 /** | 592 /** |
| 597 * @return {number} | 593 * @return {number} |
| 598 */ | 594 */ |
| 599 lastVisibleIndex: function() | 595 lastVisibleIndex: function() |
| 600 { | 596 { |
| 601 var lastVisibleIndex; | 597 var lastVisibleIndex; |
| 602 if (this._stickToBottom) | 598 if (this._stickToBottom) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 617 return null; | 613 return null; |
| 618 return this._renderedItems[index - this._firstActiveIndex].element(); | 614 return this._renderedItems[index - this._firstActiveIndex].element(); |
| 619 }, | 615 }, |
| 620 | 616 |
| 621 /** | 617 /** |
| 622 * @param {number} index | 618 * @param {number} index |
| 623 * @param {boolean=} makeLast | 619 * @param {boolean=} makeLast |
| 624 */ | 620 */ |
| 625 scrollItemIntoView: function(index, makeLast) | 621 scrollItemIntoView: function(index, makeLast) |
| 626 { | 622 { |
| 627 if (index > this._firstActiveIndex && index < this._lastActiveIndex) | 623 var firstVisibleIndex = this.firstVisibleIndex(); |
| 624 var lastVisibleIndex = this.lastVisibleIndex(); |
| 625 if (index > firstVisibleIndex && index < lastVisibleIndex) |
| 628 return; | 626 return; |
| 629 if (makeLast) | 627 if (makeLast) |
| 630 this.forceScrollItemToBeLast(index); | 628 this.forceScrollItemToBeLast(index); |
| 631 else if (index <= this._firstActiveIndex) | 629 else if (index <= firstVisibleIndex) |
| 632 this.forceScrollItemToBeFirst(index); | 630 this.forceScrollItemToBeFirst(index); |
| 633 else if (index >= this._lastActiveIndex) | 631 else if (index >= lastVisibleIndex) |
| 634 this.forceScrollItemToBeLast(index); | 632 this.forceScrollItemToBeLast(index); |
| 635 }, | 633 }, |
| 636 | 634 |
| 637 /** | 635 /** |
| 638 * @param {number} index | 636 * @param {number} index |
| 639 */ | 637 */ |
| 640 forceScrollItemToBeFirst: function(index) | 638 forceScrollItemToBeFirst: function(index) |
| 641 { | 639 { |
| 642 this.setStickToBottom(false); | 640 this.setStickToBottom(false); |
| 643 this._rebuildCumulativeHeightsIfNeeded(); | 641 this._rebuildCumulativeHeightsIfNeeded(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 662 | 660 |
| 663 /** | 661 /** |
| 664 * @return {number} | 662 * @return {number} |
| 665 */ | 663 */ |
| 666 _visibleHeight: function() | 664 _visibleHeight: function() |
| 667 { | 665 { |
| 668 // Use offsetHeight instead of clientHeight to avoid being affected by h
orizontal scroll. | 666 // Use offsetHeight instead of clientHeight to avoid being affected by h
orizontal scroll. |
| 669 return this.element.offsetHeight; | 667 return this.element.offsetHeight; |
| 670 } | 668 } |
| 671 } | 669 } |
| OLD | NEW |