Add image lazy loading

This commit is contained in:
Varun Patil 2020-10-20 03:13:10 +05:30
parent 27d55a776e
commit 8ff0e868ca
10 changed files with 123 additions and 29 deletions

View file

@ -8,6 +8,7 @@
<script src="js/localforage.min.js"></script>
<script src="js/drive.js"></script>
<script src="gameasync/mapping.js"></script>
<script src="gameasync/bitmap-map.js"></script>
<title>MKXP</title>
<style>
@ -292,6 +293,7 @@
var hideTimer = 0;
function getLazyAsset(url, filename, callback) {
const xhr = new XMLHttpRequest();
xhr.responseType = "arraybuffer";
const pdiv = document.getElementById("progress");
let showTimer = 0;
let abortTimer = 0;
@ -308,10 +310,9 @@
pdiv.style.opacity = '0';
hideTimer = 0;
}, 500);
callback();
clearTimeout(showTimer);
clearTimeout(abortTimer);
callback(xhr.response);
}
}
xhr.onprogress = function (event) {