mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Merge pull request #3842 from mikiher/dynamic-episode-row-height
Dynamically calculate episode row height on LazyEpisodeTable init
This commit is contained in:
		
						commit
						6057930507
					
				| @ -30,7 +30,7 @@ | ||||
|         <ui-text-input v-model="search" @input="inputUpdate" type="search" :placeholder="$strings.PlaceholderSearchEpisode" class="flex-grow mr-2 text-sm md:text-base" /> | ||||
|       </form> | ||||
|     </div> | ||||
|     <div class="relative min-h-[176px]"> | ||||
|     <div class="relative min-h-44"> | ||||
|       <template v-for="episode in totalEpisodes"> | ||||
|         <div :key="episode" :id="`episode-${episode - 1}`" class="w-full h-44 px-2 py-3 overflow-hidden relative border-b border-white/10"> | ||||
|           <!-- episode is mounted here --> | ||||
| @ -39,7 +39,7 @@ | ||||
|       <div v-if="isSearching" class="w-full h-full absolute inset-0 flex justify-center py-12" :class="{ 'bg-black/50': totalEpisodes }"> | ||||
|         <ui-loading-indicator /> | ||||
|       </div> | ||||
|       <div v-else-if="!totalEpisodes" class="h-44 flex items-center justify-center"> | ||||
|       <div v-else-if="!totalEpisodes" id="no-episodes" class="h-44 flex items-center justify-center"> | ||||
|         <p class="text-lg">{{ $strings.MessageNoEpisodes }}</p> | ||||
|       </div> | ||||
|     </div> | ||||
| @ -80,7 +80,7 @@ export default { | ||||
|       episodeComponentRefs: {}, | ||||
|       windowHeight: 0, | ||||
|       episodesTableOffsetTop: 0, | ||||
|       episodeRowHeight: 176, | ||||
|       episodeRowHeight: 44 * 4, // h-44, | ||||
|       currScrollTop: 0 | ||||
|     } | ||||
|   }, | ||||
| @ -538,9 +538,10 @@ export default { | ||||
|       this.episodesTableOffsetTop = (lazyEpisodesTableEl?.offsetTop || 0) + 64 | ||||
| 
 | ||||
|       this.windowHeight = window.innerHeight | ||||
|       this.episodesPerPage = Math.ceil(this.windowHeight / this.episodeRowHeight) | ||||
| 
 | ||||
|       this.$nextTick(() => { | ||||
|         this.recalcEpisodeRowHeight() | ||||
|         this.episodesPerPage = Math.ceil(this.windowHeight / this.episodeRowHeight) | ||||
|         // Maybe update currScrollTop if items were removed | ||||
|         const itemPageWrapper = document.getElementById('item-page-wrapper') | ||||
|         const { scrollHeight, clientHeight } = itemPageWrapper | ||||
| @ -548,6 +549,13 @@ export default { | ||||
|         this.currScrollTop = Math.min(this.currScrollTop, maxScrollTop) | ||||
|         this.handleScroll() | ||||
|       }) | ||||
|     }, | ||||
|     recalcEpisodeRowHeight() { | ||||
|       const episodeRowEl = document.getElementById('episode-0') || document.getElementById('no-episodes') | ||||
|       if (episodeRowEl) { | ||||
|         const height = getComputedStyle(episodeRowEl).height | ||||
|         this.episodeRowHeight = parseInt(height) || this.episodeRowHeight | ||||
|       } | ||||
|     } | ||||
|   }, | ||||
|   mounted() { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user