mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-27 01:53:48 +01:00
Merge pull request #1303 from Nolshine/fix_status_text_animation_not_resetting
fix status text animation not resetting properly
This commit is contained in:
commit
48eb0df99f
@ -10,21 +10,27 @@ let x: number | undefined;
|
|||||||
* @param text The status text to display
|
* @param text The status text to display
|
||||||
*/
|
*/
|
||||||
export function createStatusText(text: string): void {
|
export function createStatusText(text: string): void {
|
||||||
if (x !== undefined) {
|
|
||||||
clearTimeout(x);
|
|
||||||
// Likely not needed due to clearTimeout, but just in case...
|
|
||||||
x = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const statusElement: HTMLElement = getElementById("status-text");
|
const statusElement: HTMLElement = getElementById("status-text");
|
||||||
statusElement.style.display = "block";
|
|
||||||
statusElement.classList.add("status-text");
|
|
||||||
statusElement.innerText = text;
|
|
||||||
const handler: Action = () => {
|
const handler: Action = () => {
|
||||||
statusElement.innerText = "";
|
statusElement.innerText = "";
|
||||||
statusElement.style.display = "none";
|
statusElement.style.display = "none";
|
||||||
statusElement.classList.remove("status-text");
|
statusElement.classList.remove("status-text");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (x !== undefined) {
|
||||||
|
clearTimeout(x);
|
||||||
|
// Likely not needed due to clearTimeout, but just in case...
|
||||||
|
x = undefined;
|
||||||
|
// reset the element's animation
|
||||||
|
statusElement.style.animation = 'none';
|
||||||
|
setTimeout(function() {
|
||||||
|
statusElement.style.animation = '';
|
||||||
|
}, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
statusElement.style.display = "block";
|
||||||
|
statusElement.classList.add("status-text");
|
||||||
|
statusElement.innerText = text;
|
||||||
|
|
||||||
x = setTimeoutRef(handler, threeSeconds);
|
x = setTimeoutRef(handler, threeSeconds);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user