From 1fd0e52e34b0b1ebf86cce33d0bfe0650c31874e Mon Sep 17 00:00:00 2001 From: Aroooba Date: Sun, 7 Jan 2024 21:53:50 +0900 Subject: [PATCH] Clear timers and event listeners before component unmounts --- docs/src/components/CodeExample.vue | 10 ++++++++-- docs/src/components/Navigation.vue | 18 ++++++++++++++---- docs/src/components/TheLogo.vue | 4 ++++ docs/src/examples/cards/ActualCards.vue | 10 ++++++++-- docs/src/examples/disable/ActualDisable.vue | 11 +++++++++-- docs/src/examples/disable/disable.vue | 11 +++++++++-- 6 files changed, 52 insertions(+), 12 deletions(-) diff --git a/docs/src/components/CodeExample.vue b/docs/src/components/CodeExample.vue index 35fa1c0..f1f5318 100644 --- a/docs/src/components/CodeExample.vue +++ b/docs/src/components/CodeExample.vue @@ -12,10 +12,12 @@ import IconJavaScript from "./IconJavaScript.vue" import IconSvelte from "./IconSvelte.vue" import IconAngular from "./IconAngular.vue" import IconNuxt from "./IconNuxt.vue" -import { computed, ref } from "vue" +import { computed, ref, onBeforeUnmount } from "vue"; import { vAutoAnimate } from "../../../src" import "../../assets/prism.css" +const timeOutID = ref(); + type LanguageOption = | "react" | "preact" @@ -77,10 +79,14 @@ const copyStatus = ref(false) function copyCode(value: string) { window.navigator.clipboard.writeText(value) copyStatus.value = true - setTimeout(() => { + timeOutID.value = setTimeout(() => { copyStatus.value = false }, 2000) } + +onBeforeUnmount(() => { + clearTimeout(timeOutID.value); +});