Skip to content

Commit

Permalink
chore: fix update
Browse files Browse the repository at this point in the history
  • Loading branch information
jiazengp committed May 5, 2024
1 parent ca76d35 commit e4242b8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions kumiko-awesome.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class KumikoAwesome {
#audiosStack = []

constructor(image, audio) {
this.row = Math.ceil(window.innerHeight / 120) * 4
this.count = Math.ceil(window.innerWidth / 120) * 8
this.row = Math.ceil(window.innerHeight / 120) * 2
this.count = window.innerWidth < 720 ? 50 : Math.ceil(window.innerWidth / 120) * 8
this.images = [...image]
this.audios = [...audio]
console.log(this.row , this.count)
Expand Down Expand Up @@ -78,16 +78,15 @@ class KumikoAwesome {
return new Audio(this.#audiosStack.pop()).play()
}

preloadResource(images, audios) {
preloadResource() {
this.images.forEach(val => addPreloadLink(val, 'image'))
this.audios.forEach(val => addPreloadLink(val, 'audio'))

function addPreloadLink(href, as, type) {
function addPreloadLink(href, as) {
const linkElement = document.createElement("link")
linkElement.href = href
linkElement.rel = 'preload'
linkElement.as = as
linkElement.type = type
document.head.appendChild(linkElement)
}
}
Expand Down

0 comments on commit e4242b8

Please sign in to comment.