From 786809d5ca8c0da38c58f6e71ee2dbdb0b5ade2c Mon Sep 17 00:00:00 2001 From: MarcusNyne <69087098+MarcusNyne@users.noreply.github.com> Date: Sat, 24 Aug 2024 20:21:05 -0400 Subject: [PATCH] fixed a bug where copy animation remained --- script.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/script.js b/script.js index 1a0906067..e6dff8e95 100644 --- a/script.js +++ b/script.js @@ -213,6 +213,16 @@ function uiElementInSight(el) { return isOnScreen; } +function uiCopyElementAnimate(el) { + el.classList.remove('animate'); + setTimeout(() => { + el.classList.add('animate'); + }, 0); + setTimeout(() => { + el.classList.remove('animate'); + }, 1100); +} + function uiCopyElementText(el) { var text = el.innerText; if (text.startsWith('"')) { @@ -220,11 +230,7 @@ function uiCopyElementText(el) { } navigator.clipboard.writeText(text); - - el.classList.remove('animate'); - setTimeout(() => { - el.classList.add('animate'); - }, 0); + uiCopyElementAnimate(el); } function uiCopyRawText(elid) { @@ -266,10 +272,6 @@ function uiCopyPngInfo(el, mode) { if (text != null) { navigator.clipboard.writeText(text); - - el.classList.remove('animate'); - setTimeout(() => { - el.classList.add('animate'); - }, 0); + uiCopyElementAnimate(el); } }