Skip to content

Commit

Permalink
🐛 Improve episode image management
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Oct 11, 2024
1 parent 1e12ed5 commit 714b807
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
22 changes: 10 additions & 12 deletions pages/episode/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ async function loadEpisodeInfos(){
});
}
function removeLoadingClass(event: Event){
const target = event.target as HTMLImageElement;
target.classList.remove("loading-episode");
}
onMounted(async() => {
loadEpisodeImages();
loadEpisodeInfos();
Expand All @@ -83,18 +78,23 @@ onMounted(async() => {
<div v-for="(image, index) of episodeImages.slice(0, maxIndex)" :key="index" class="w-full">
<NuxtImg
v-if="index < maxIndex - 1"
:id="image"
:src="sumToImageUrl(image)"
format="webp"
alt="Episode Image"
class="w-full loading-episode"
@load="removeLoadingClass"
class="w-full"
width="800"
height="1280"
/>
<VisibilityObserver v-else @on-display="increaseMaxIndex">
<NuxtImg
:id="image"
:src="sumToImageUrl(image)"
format="webp"
alt="Episode Image"
class="w-full loading-episode"
@load="removeLoadingClass"
class="w-full"
width="800"
height="1280"
/>
</VisibilityObserver>
</div>
Expand All @@ -110,7 +110,5 @@ onMounted(async() => {
</template>

<style scoped>
.loading-episode{
@apply h-96;
}
</style>
4 changes: 4 additions & 0 deletions utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export function getOrder(webtoonId: number): boolean{
}

export function startEpisode(episodeId: number): void{
if(import.meta.server)
return;
let episodes = localStorage.getItem("episode");
if(episodes){
episodes = JSON.parse(episodes);
Expand All @@ -32,6 +34,8 @@ export function startEpisode(episodeId: number): void{
}

export function isEpisodeStarted(episodeId: number): boolean{
if(import.meta.server)
return;
let episodes = localStorage.getItem("episode");
if(episodes){
episodes = JSON.parse(episodes);
Expand Down

0 comments on commit 714b807

Please sign in to comment.