@@ -82,6 +82,10 @@ export class IronListAdapter {
82
82
return this . lastVisibleIndex + this . _vidxOffset ;
83
83
}
84
84
85
+ get _maxVirtualIndexOffset ( ) {
86
+ return this . size - this . _virtualCount ;
87
+ }
88
+
85
89
__hasPlaceholders ( ) {
86
90
return this . __getVisibleElements ( ) . some ( ( el ) => el . __virtualizerPlaceholder ) ;
87
91
}
@@ -106,7 +110,7 @@ export class IronListAdapter {
106
110
let targetVirtualIndex = Math . floor ( ( index / this . size ) * this . _virtualCount ) ;
107
111
if ( this . _virtualCount - targetVirtualIndex < visibleElementCount ) {
108
112
targetVirtualIndex = this . _virtualCount - ( this . size - index ) ;
109
- this . _vidxOffset = this . size - this . _virtualCount ;
113
+ this . _vidxOffset = this . _maxVirtualIndexOffset ;
110
114
} else if ( targetVirtualIndex < visibleElementCount ) {
111
115
if ( index < OFFSET_ADJUST_MIN_THRESHOLD ) {
112
116
targetVirtualIndex = index ;
@@ -719,15 +723,16 @@ export class IronListAdapter {
719
723
720
724
/** @private */
721
725
_adjustVirtualIndexOffset ( delta ) {
726
+ const maxOffset = this . _maxVirtualIndexOffset ;
727
+
722
728
if ( this . _virtualCount >= this . size ) {
723
729
this . _vidxOffset = 0 ;
724
730
} else if ( this . __skipNextVirtualIndexAdjust ) {
725
731
this . __skipNextVirtualIndexAdjust = false ;
726
732
} else if ( Math . abs ( delta ) > 10000 ) {
727
733
// Process a large scroll position change
728
- const scale = this . _scrollTop / ( this . scrollTarget . scrollHeight - this . scrollTarget . offsetHeight ) ;
729
- const offset = scale * this . size ;
730
- this . _vidxOffset = Math . round ( offset - scale * this . _virtualCount ) ;
734
+ const scale = this . _scrollTop / ( this . scrollTarget . scrollHeight - this . scrollTarget . clientHeight ) ;
735
+ this . _vidxOffset = Math . round ( scale * maxOffset ) ;
731
736
} else {
732
737
// Make sure user can always swipe/wheel scroll to the start and end
733
738
const oldOffset = this . _vidxOffset ;
@@ -746,7 +751,6 @@ export class IronListAdapter {
746
751
}
747
752
748
753
// Near end
749
- const maxOffset = this . size - this . _virtualCount ;
750
754
if ( this . _scrollTop >= this . _maxScrollTop && this . _maxScrollTop > 0 ) {
751
755
this . _vidxOffset = maxOffset ;
752
756
if ( oldOffset !== this . _vidxOffset ) {
0 commit comments