From 6bbef91c402eaa58b8a4d8f11c466a39802ca0ca Mon Sep 17 00:00:00 2001 From: 劉鈞霖 <benson@gmail.com> Date: 星期二, 28 十二月 2021 14:50:13 +0800 Subject: [PATCH] [ Ref ] : 重構 共用資料夾 相關元件 --- PAMapp/components/Ui/UiGoToTop.vue | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/PAMapp/components/Ui/UiGoToTop.vue b/PAMapp/components/Ui/UiGoToTop.vue index 2fe1bd7..8ceb2f7 100644 --- a/PAMapp/components/Ui/UiGoToTop.vue +++ b/PAMapp/components/Ui/UiGoToTop.vue @@ -16,11 +16,19 @@ export default class UiGoToTop extends Vue { buttonDisplay = 'none'; + ////////////////////////////////////////////////////////////////// + created() { if (process.browser) { document.body.addEventListener('scroll', this.scrollFunction); } } + + destroyed() { + document.body.removeEventListener('scroll', this.scrollFunction); + } + + ////////////////////////////////////////////////////////////////// scrollFunction() { if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 300) { @@ -33,10 +41,6 @@ topFunction() { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; - } - - destroyed() { - document.body.removeEventListener('scroll', this.scrollFunction); } } </script> @@ -66,4 +70,4 @@ background-color: $MID_GREY; } } -</style> \ No newline at end of file +</style> -- Gitblit v1.8.0