Pārlūkot izejas kodu

Made “prel()” also load previous-previuos and next-next images

pezcurrel 2 nedēļas atpakaļ
vecāks
revīzija
32a1ab4f3c
1 mainītis faili ar 18 papildinājumiem un 8 dzēšanām
  1. 18 8
      pfaltgall

+ 18 - 8
pfaltgall

@@ -413,30 +413,40 @@ function prel() {
 	pages=Math.round(th/ph),
 	sy=Math.round(md.scrollTop),
 	page=Math.round(pages-(th-sy)/ph)+1,
-	img,
-	u;
+	img;
 	//console.log(ph+" "+th+" "+pages+" "+sy+" "+page);
 	if (page>1) {//current
 		img=document.getElementById("img"+(page-2));
 		if (img.src==phimgurl) {
-			u=imgurls[page-2];
-			img.src=u;
+			img.src=imgurls[page-2];
 			img.loading="eager";
 		}
 	}
 	if (page<pages) {//next
 		img=document.getElementById("img"+(page-1));
 		if (img.src==phimgurl) {
-			u=imgurls[page-1];
-			img.src=u;
+			img.src=imgurls[page-1];
 			img.loading="eager";
 		}
 	}
 	if (page>2) {//previous
 		img=document.getElementById("img"+(page-3));
 		if (img.src==phimgurl) {
-			u=imgurls[page-3];
-			img.src=u;
+			img.src=imgurls[page-3];
+			img.loading="eager";
+		}
+	}
+	if (page+1<pages) {//next-next
+		img=document.getElementById("img"+page);
+		if (img.src==phimgurl) {
+			img.src=imgurls[page];
+			img.loading="eager";
+		}
+	}
+	if (page>3) {//previous-previous
+		img=document.getElementById("img"+(page-4));
+		if (img.src==phimgurl) {
+			img.src=imgurls[page-4];
 			img.loading="eager";
 		}
 	}