WIP
This commit is contained in:
parent
cb0a79d1e0
commit
617adace59
@ -89,7 +89,7 @@ $(async function () {
|
||||
preloaded = false;
|
||||
var loadedimages = {};
|
||||
for (let i=0; i<emotes.length; i++) {
|
||||
var image = new Image();
|
||||
const image = new Image();
|
||||
image.onload = function () {
|
||||
loadcount++;
|
||||
if (loadcount == loadtotal) preloaded = true;
|
||||
@ -102,19 +102,16 @@ $(async function () {
|
||||
|
||||
|
||||
const loadImagesTwitch = async(emotesId) => {
|
||||
let loadcount = 0;
|
||||
let loadtotal = emotesId.length;
|
||||
var localPreloaded = false;
|
||||
const promiseArray = [];
|
||||
for (let i=0; i<emotesId.length; i++) {
|
||||
var image = new Image();
|
||||
image.onload = function () {
|
||||
loadcount++;
|
||||
if (loadcount == loadtotal) localPreloaded = true;
|
||||
};
|
||||
promiseArray.push(new Promise(resolve => {
|
||||
const image = new Image();
|
||||
image.onload = () => resolve();
|
||||
image.src = "https://static-cdn.jtvnw.net/emoticons/v2/" + emotesId[i] + "/default/dark/2.0";
|
||||
img_map[emotesId[i]] = image;
|
||||
}));
|
||||
}
|
||||
await waitFor(_ => localPreloaded === true);
|
||||
await Promise.all(promiseArray);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user