From 5936575888df5cd2611e1c7a7bc1017117de7ba5 Mon Sep 17 00:00:00 2001 From: liyunze <50455574+liyunze-coding@users.noreply.github.com> Date: Mon, 21 Aug 2023 11:37:43 +0800 Subject: [PATCH] Optimized listener events --- configs.js | 6 +++--- scripts/taskList.js | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/configs.js b/configs.js index 317becf..2f54836 100644 --- a/configs.js +++ b/configs.js @@ -3,12 +3,12 @@ const configs = (function () { // settings const enableLimit = true; // true or false - const limit = 10; // integer + const limit = 5; // integer // animation - const scrollSpeed = 30; // milliseconds (DO NOT PUT BELOW 5, COMPUTER MIGHT CRASH) the lower the value, the faster the scroll + const scrollSpeed = 30; // milliseconds const pauseBetweenScrolls = 2000; // milliseconds - const gapBetweenScrolls = "100px"; // px + const gapBetweenScrolls = "50px"; // px // STYLES // task list diff --git a/scripts/taskList.js b/scripts/taskList.js index 5c3db54..08192d4 100644 --- a/scripts/taskList.js +++ b/scripts/taskList.js @@ -857,7 +857,12 @@ async function checkToAnimate() { document.querySelector(".secondary").style.display = "none"; // cancel animations - cancelAnimation(); + if (primaryAnimation) { + primaryAnimation.cancel(); + } + if (secondaryAnimation) { + secondaryAnimation.cancel(); + } scrolling = false; } } @@ -867,10 +872,6 @@ function addAnimationListeners() { primaryAnimation.addEventListener("finish", animationFinished); primaryAnimation.addEventListener("cancel", animationFinished); } - if (secondaryAnimation) { - secondaryAnimation.addEventListener("finish", animationFinished); - secondaryAnimation.addEventListener("cancel", animationFinished); - } } function animationFinished() { @@ -887,6 +888,7 @@ function cancelAnimation() { secondaryAnimation.cancel(); } scrolling = false; + console.log("animation cancelled"); } (function () {