@@ -214,7 +214,7 @@ export class VirtualRepeat extends AbstractRepeater {
214214 _prevItemsCount : number ;
215215
216216 /**@internal */
217- containerEl : HTMLElement ;
217+ scrollerEl : HTMLElement ;
218218
219219 /**@internal */
220220 private scrollListener : ( ) => any ;
@@ -339,7 +339,7 @@ export class VirtualRepeat extends AbstractRepeater {
339339 const scrollListener = this . scrollListener = ( ) => {
340340 this . _onScroll ( ) ;
341341 } ;
342- const containerEl = this . containerEl = templateStrategy . getScrollContainer ( element ) ;
342+ const containerEl = this . scrollerEl = templateStrategy . getScrollContainer ( element ) ;
343343 const [ topBufferEl , bottomBufferEl ] = templateStrategy . createBuffers ( element ) ;
344344
345345 this . topBufferEl = topBufferEl ;
@@ -377,7 +377,7 @@ export class VirtualRepeat extends AbstractRepeater {
377377
378378 /**@override */
379379 detached ( ) : void {
380- const scrollCt = this . containerEl ;
380+ const scrollCt = this . scrollerEl ;
381381 const scrollListener = this . scrollListener ;
382382 if ( hasOverflowScroll ( scrollCt ) ) {
383383 scrollCt . removeEventListener ( 'scroll' , scrollListener ) ;
@@ -390,7 +390,7 @@ export class VirtualRepeat extends AbstractRepeater {
390390 this . _unsubscribeCollection ( ) ;
391391 this . _resetCalculation ( ) ;
392392 this . templateStrategy . removeBuffers ( this . element , this . topBufferEl , this . bottomBufferEl ) ;
393- this . topBufferEl = this . bottomBufferEl = this . containerEl = this . scrollListener = null ;
393+ this . topBufferEl = this . bottomBufferEl = this . scrollerEl = this . scrollListener = null ;
394394 this . removeAllViews ( /*return to cache?*/ true , /*skip animation?*/ false ) ;
395395 const $clearInterval = PLATFORM . global . clearInterval ;
396396 $clearInterval ( this . _calcDistanceToTopInterval ) ;
@@ -439,7 +439,7 @@ export class VirtualRepeat extends AbstractRepeater {
439439 throw new Error ( 'Value is not iterateable for virtual repeat.' ) ;
440440 }
441441
442- const scroller = this . containerEl ;
442+ const scroller = this . scrollerEl ;
443443 if ( shouldCalculateSize ) {
444444 const currentItemCount = items . length ;
445445 if ( currentItemCount > 0 && this . viewCount ( ) === 0 ) {
@@ -528,7 +528,7 @@ export class VirtualRepeat extends AbstractRepeater {
528528 */
529529 getScroller ( ) : HTMLElement {
530530 return this . _fixedHeightContainer
531- ? this . containerEl
531+ ? this . scrollerEl
532532 : document . documentElement ;
533533 }
534534
@@ -541,7 +541,7 @@ export class VirtualRepeat extends AbstractRepeater {
541541 scroller : scroller ,
542542 scrollHeight : scroller . scrollHeight ,
543543 scrollTop : scroller . scrollTop ,
544- height : scroller . clientHeight
544+ height : calcScrollHeight ( scroller )
545545 } ;
546546 }
547547
@@ -595,7 +595,7 @@ export class VirtualRepeat extends AbstractRepeater {
595595 return ;
596596 }
597597 const topBufferEl = this . topBufferEl ;
598- const scrollerEl = this . containerEl ;
598+ const scrollerEl = this . scrollerEl ;
599599 const itemHeight = this . itemHeight ;
600600 /**
601601 * Real scroll top calculated based on current scroll top of scroller and top buffer {height + distance to top}
@@ -661,9 +661,7 @@ export class VirtualRepeat extends AbstractRepeater {
661661 this . _switchedDirection = false ;
662662 this . _topBufferHeight = currentTopBufferHeight + adjustHeight ;
663663 this . _bottomBufferHeight = Math$max ( currentBottomBufferHeight - adjustHeight , 0 ) ;
664- if ( this . _bottomBufferHeight >= 0 ) {
665- this . _updateBufferElements ( true ) ;
666- }
664+ this . _updateBufferElements ( true ) ;
667665 } else if ( this . _scrollingUp ) {
668666 const isLastIndex = this . isLastIndex ;
669667 let viewsToMoveCount = currLastReboundIndex - firstIndex ;
@@ -689,9 +687,7 @@ export class VirtualRepeat extends AbstractRepeater {
689687 this . _switchedDirection = false ;
690688 this . _topBufferHeight = Math$max ( currentTopBufferHeight - adjustHeight , 0 ) ;
691689 this . _bottomBufferHeight = currentBottomBufferHeight + adjustHeight ;
692- if ( this . _topBufferHeight >= 0 ) {
693- this . _updateBufferElements ( true ) ;
694- }
690+ this . _updateBufferElements ( true ) ;
695691 }
696692 this . _previousFirst = firstIndex ;
697693 this . _isScrolling = false ;
@@ -777,8 +773,8 @@ export class VirtualRepeat extends AbstractRepeater {
777773 const { _first, _scrollingUp, _scrollingDown, _previousFirst } = this ;
778774
779775 let isScrolling = false ;
780- let isScrollingDown = false ;
781- let isScrollingUp = false ;
776+ let isScrollingDown = _scrollingDown ;
777+ let isScrollingUp = _scrollingUp ;
782778 let isSwitchedDirection = false ;
783779
784780 if ( _first > _previousFirst
@@ -927,9 +923,9 @@ export class VirtualRepeat extends AbstractRepeater {
927923 this . _prevItemsCount = itemsLength ;
928924 const itemHeight = this . itemHeight ;
929925 const scrollContainerHeight = this . _fixedHeightContainer
930- ? calcScrollHeight ( this . containerEl )
926+ ? calcScrollHeight ( this . scrollerEl )
931927 : document . documentElement . clientHeight ;
932- const elementsInView = this . elementsInView = Math$ceil ( scrollContainerHeight / itemHeight ) + 1 ;
928+ const elementsInView = this . elementsInView = Math$floor ( scrollContainerHeight / itemHeight ) + 1 ;
933929 const viewsCount = this . _viewsLength = elementsInView * 2 ;
934930
935931 // Look at top buffer height (how far we've scrolled down)
0 commit comments