From 0a18ee1c89962cfee6b81b018d9bb7d007d486f7 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 10 Jan 2024 11:34:30 +0800 Subject: globaled mainInterval --- public/js/randomblob.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'public') diff --git a/public/js/randomblob.js b/public/js/randomblob.js index 5ea80ed1..a32045f2 100644 --- a/public/js/randomblob.js +++ b/public/js/randomblob.js @@ -1,6 +1,7 @@ "use strict"; var isFirstTime = true; +var mainInterval; function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); @@ -50,9 +51,10 @@ function main() { resetBlob(); isFirstTime = false; } - setTimeout(main, getRandomInt(7500, 30000)); + mainInterval = setTimeout(main, getRandomInt(7500, 30000)); } blob.addEventListener('click', function () { + clearTimeout(mainInterval); main(getRandomInt(7500, 30000)); }); main(); \ No newline at end of file -- cgit v1.2.3