@@ -89,6 +89,10 @@ export class IronListAdapter {
89
89
return this . lastVisibleIndex + this . _vidxOffset ;
90
90
}
91
91
92
+ get _maxVirtualIndexOffset ( ) {
93
+ return this . size - this . _virtualCount ;
94
+ }
95
+
92
96
__hasPlaceholders ( ) {
93
97
return this . __getVisibleElements ( ) . some ( ( el ) => el . __virtualizerPlaceholder ) ;
94
98
}
@@ -113,7 +117,7 @@ export class IronListAdapter {
113
117
let targetVirtualIndex = Math . floor ( ( index / this . size ) * this . _virtualCount ) ;
114
118
if ( this . _virtualCount - targetVirtualIndex < visibleElementCount ) {
115
119
targetVirtualIndex = this . _virtualCount - ( this . size - index ) ;
116
- this . _vidxOffset = this . size - this . _virtualCount ;
120
+ this . _vidxOffset = this . _maxVirtualIndexOffset ;
117
121
} else if ( targetVirtualIndex < visibleElementCount ) {
118
122
if ( index < OFFSET_ADJUST_MIN_THRESHOLD ) {
119
123
targetVirtualIndex = index ;
@@ -769,15 +773,16 @@ export class IronListAdapter {
769
773
770
774
/** @private */
771
775
_adjustVirtualIndexOffset ( delta ) {
776
+ const maxOffset = this . _maxVirtualIndexOffset ;
777
+
772
778
if ( this . _virtualCount >= this . size ) {
773
779
this . _vidxOffset = 0 ;
774
780
} else if ( this . __skipNextVirtualIndexAdjust ) {
775
781
this . __skipNextVirtualIndexAdjust = false ;
776
782
} else if ( Math . abs ( delta ) > 10000 ) {
777
783
// Process a large scroll position change
778
784
const scale = this . _scrollTop / ( this . scrollTarget . scrollHeight - this . scrollTarget . offsetHeight ) ;
779
- const offset = scale * this . size ;
780
- this . _vidxOffset = Math . round ( offset - scale * this . _virtualCount ) ;
785
+ this . _vidxOffset = Math . round ( scale * maxOffset ) ;
781
786
} else {
782
787
// Make sure user can always swipe/wheel scroll to the start and end
783
788
const oldOffset = this . _vidxOffset ;
@@ -796,7 +801,6 @@ export class IronListAdapter {
796
801
}
797
802
798
803
// Near end
799
- const maxOffset = this . size - this . _virtualCount ;
800
804
if ( this . _scrollTop >= this . _maxScrollTop && this . _maxScrollTop > 0 ) {
801
805
this . _vidxOffset = maxOffset ;
802
806
if ( oldOffset !== this . _vidxOffset ) {
0 commit comments