summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-01-10 11:34:30 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-01-10 11:34:30 +0800
commit0a18ee1c89962cfee6b81b018d9bb7d007d486f7 (patch)
tree613fae6c6f08f408b489424ec2a3850b3a028179
parent409a97f13b17c6a9423a958a2e7c4dd0fd029671 (diff)
globaled mainInterval
-rw-r--r--public/js/randomblob.js4
-rw-r--r--src/js/randomblob.js3
2 files changed, 5 insertions, 2 deletions
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
diff --git a/src/js/randomblob.js b/src/js/randomblob.js
index 3e068255..4c9dbc07 100644
--- a/src/js/randomblob.js
+++ b/src/js/randomblob.js
@@ -1,4 +1,5 @@
let isFirstTime = true;
+var mainInterval;
function getRandomInt(min, max) {
min = Math.ceil(min);
@@ -59,7 +60,7 @@ function main() {
resetBlob()
isFirstTime = false;
}
- let mainInterval = setTimeout(main, getRandomInt(7500, 30000));
+ mainInterval = setTimeout(main, getRandomInt(7500, 30000));
}
blob.addEventListener('click', function() {