Skip to content

Commit

Permalink
improve preloading
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan committed Dec 12, 2022
1 parent f9e8876 commit 9482a3d
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions packages/web-app-preview/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -564,22 +564,36 @@ export default defineComponent({
})
}
console.log('active index: ', this.activeIndex)
const preloadUpcomingFile = (upcomingFileIndex) => {
let cycleIndex =
(((this.activeIndex + upcomingFileIndex) % this.filteredFiles.length) +
this.filteredFiles.length) %
this.filteredFiles.length
for (
let followingFileIndex = 1;
followingFileIndex <= PRELOAD_IMAGE_COUNT;
followingFileIndex++
) {
let cycleIndex = (this.activeIndex + followingFileIndex) % this.activeFiles.length
const file = this.filteredFiles[cycleIndex]
if (!this.isFileTypeImage(file) || toPreloadFiles.includes(file.id)) {
continue
return
}
loadPreviewAsync(file)
}
for (
let followingFileIndex = 1;
followingFileIndex <= PRELOAD_IMAGE_COUNT;
followingFileIndex++
) {
preloadUpcomingFile(followingFileIndex)
}
for (
let previousFileIndex = -1;
previousFileIndex >= PRELOAD_IMAGE_COUNT * -1;
previousFileIndex--
) {
preloadUpcomingFile(previousFileIndex)
}
}
}
})
Expand Down

0 comments on commit 9482a3d

Please sign in to comment.