Skip to content

Commit

Permalink
Merge pull request #3842 from mikiher/dynamic-episode-row-height
Browse files Browse the repository at this point in the history
Dynamically calculate episode row height on LazyEpisodeTable init
  • Loading branch information
advplyr authored Jan 15, 2025
2 parents 9bbb23b + e865241 commit 6057930
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions client/components/tables/podcast/LazyEpisodesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand All @@ -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>
Expand Down Expand Up @@ -80,7 +80,7 @@ export default {
episodeComponentRefs: {},
windowHeight: 0,
episodesTableOffsetTop: 0,
episodeRowHeight: 176,
episodeRowHeight: 44 * 4, // h-44,
currScrollTop: 0
}
},
Expand Down Expand Up @@ -538,16 +538,24 @@ 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
const maxScrollTop = scrollHeight - clientHeight
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() {
Expand Down

0 comments on commit 6057930

Please sign in to comment.