Prefetch next image #185
This commit is contained in:
parent
a90e066729
commit
6464d6bcc6
BIN
dist/main.js
vendored
BIN
dist/main.js
vendored
Binary file not shown.
@ -56,7 +56,7 @@ photo.load = function(photoID, albumID) {
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
lychee.content.show()
|
lychee.content.show()
|
||||||
//photo.preloadNext(photoID, albumID);
|
photo.preloadNext(photoID);
|
||||||
}, 300)
|
}, 300)
|
||||||
|
|
||||||
})
|
})
|
||||||
@ -66,21 +66,16 @@ photo.load = function(photoID, albumID) {
|
|||||||
// Preload the next photo for better response time
|
// Preload the next photo for better response time
|
||||||
photo.preloadNext = function(photoID) {
|
photo.preloadNext = function(photoID) {
|
||||||
|
|
||||||
// Never preload on mobile devices with bare RAM and
|
|
||||||
// mostly mobile internet
|
|
||||||
// {{ code }}
|
|
||||||
|
|
||||||
if (album.json &&
|
if (album.json &&
|
||||||
album.json.content &&
|
album.json.content &&
|
||||||
album.json.content[photoID] &&
|
album.json.content[photoID] &&
|
||||||
album.json.content[photoID].nextPhoto!='') {
|
album.json.content[photoID].nextPhoto!='') {
|
||||||
|
|
||||||
let nextPhoto = album.json.content[photoID].nextPhoto,
|
let nextPhoto = album.json.content[photoID].nextPhoto,
|
||||||
url = album.json.content[nextPhoto].url
|
url = album.json.content[nextPhoto].url
|
||||||
|
|
||||||
photo.cache = new Image()
|
$('head [data-prefetch]').remove()
|
||||||
photo.cache.src = url
|
$('head').append(`<link data-prefetch rel="prefetch" href="${ url }">`)
|
||||||
photo.cache.onload = () => photo.cache = null
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user