@@ -80,7 +80,8 @@ export default {
80
80
episodeComponentRefs: {},
81
81
windowHeight: 0 ,
82
82
episodesTableOffsetTop: 0 ,
83
- episodeRowHeight: 176
83
+ episodeRowHeight: 176 ,
84
+ currScrollTop: 0
84
85
}
85
86
},
86
87
watch: {
@@ -484,9 +485,8 @@ export default {
484
485
}
485
486
}
486
487
},
487
- scroll (evt ) {
488
- if (! evt? .target ? .scrollTop ) return
489
- const scrollTop = Math .max (evt .target .scrollTop - this .episodesTableOffsetTop , 0 )
488
+ handleScroll () {
489
+ const scrollTop = this .currScrollTop
490
490
let firstEpisodeIndex = Math .floor (scrollTop / this .episodeRowHeight )
491
491
let lastEpisodeIndex = Math .ceil ((scrollTop + this .windowHeight ) / this .episodeRowHeight )
492
492
lastEpisodeIndex = Math .min (this .totalEpisodes - 1 , lastEpisodeIndex)
@@ -501,6 +501,12 @@ export default {
501
501
})
502
502
this .mountEpisodes (firstEpisodeIndex, lastEpisodeIndex + 1 )
503
503
},
504
+ scroll (evt ) {
505
+ if (! evt? .target ? .scrollTop ) return
506
+ const scrollTop = Math .max (evt .target .scrollTop - this .episodesTableOffsetTop , 0 )
507
+ this .currScrollTop = scrollTop
508
+ this .handleScroll ()
509
+ },
504
510
initListeners () {
505
511
const itemPageWrapper = document .getElementById (' item-page-wrapper' )
506
512
if (itemPageWrapper) {
@@ -535,7 +541,12 @@ export default {
535
541
this .episodesPerPage = Math .ceil (this .windowHeight / this .episodeRowHeight )
536
542
537
543
this .$nextTick (() => {
538
- this .mountEpisodes (0 , Math .min (this .episodesPerPage , this .totalEpisodes ))
544
+ // Maybe update currScrollTop if items were removed
545
+ const itemPageWrapper = document .getElementById (' item-page-wrapper' )
546
+ const { scrollHeight , clientHeight } = itemPageWrapper
547
+ const maxScrollTop = scrollHeight - clientHeight
548
+ this .currScrollTop = Math .min (this .currScrollTop , maxScrollTop)
549
+ this .handleScroll ()
539
550
})
540
551
}
541
552
},
0 commit comments