From 4f66814433a970efa7b174cf9819bf6db6f985bf Mon Sep 17 00:00:00 2001 From: sD Date: Wed, 18 Mar 2020 19:39:55 +0100 Subject: move preanim delay out of the case block --- webAO/client.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'webAO') diff --git a/webAO/client.js b/webAO/client.js index 4a42306..89c4b6d 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1327,8 +1327,7 @@ async changeBackground(position) { * Intialize updater * @param {number} animdelay the length of pre-animation */ - initUpdater(animdelay) { - viewport.chatmsg.preanimdelay = parseInt(animdelay); + initUpdater() { viewport.updater = setTimeout(() => viewport.tick(), UPDATE_INTERVAL); } @@ -1493,7 +1492,7 @@ async changeBackground(position) { const fg = document.getElementById("client_fg"); const gamewindow = document.getElementById("client_gamewindow"); - let delay = 0; + let gifLength = 0; // stop updater clearTimeout(this.updater); @@ -1584,8 +1583,7 @@ async changeBackground(position) { chatBox.style.display = "none"; chatContainerBox.style.display = "none"; // If preanim existed then determine the length - delay = await this.getAnimLength(`${AO_HOST}characters/${encodeURI(chatmsg.name.toLowerCase())}/${encodeURI(chatmsg.preanim)}.gif`); - chatmsg.preanimdelay = delay; + gifLength = await this.getAnimLength(`${AO_HOST}characters/${encodeURI(chatmsg.name.toLowerCase())}/${encodeURI(chatmsg.preanim)}.gif`); this.chatmsg.startspeaking = false; break; // case 5: @@ -1596,6 +1594,7 @@ async changeBackground(position) { this.chatmsg.startspeaking = true; break; } + this.chatmsg.preanimdelay = parseInt(gifLength); this.changeBackground(chatmsg.side); @@ -1615,7 +1614,7 @@ async changeBackground(position) { } } - this.initUpdater(delay); + this.initUpdater(); } /** -- cgit