From 6b7a18b967b2faf762c844bf302bee2629e68a58 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Fri, 19 Aug 2022 14:25:08 -0700 Subject: [PATCH] fix: :bug: scroll --- packages/client/src/ui/universal.vue | 33 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/packages/client/src/ui/universal.vue b/packages/client/src/ui/universal.vue index e026b4562..d8f66d54f 100644 --- a/packages/client/src/ui/universal.vue +++ b/packages/client/src/ui/universal.vue @@ -133,6 +133,22 @@ onMounted(() => { if (!isDesktop.value) { window.addEventListener('resize', () => { if (window.innerWidth >= DESKTOP_THRESHOLD) isDesktop.value = true; + let scrollPos = 0; + const postButton = document.getElementById('postButton'); + + function checkPosition() { + let windowY = window.scrollY; + if (postButton != null) { + if (windowY < scrollPos) { + postButton.style.transform = 'scale(1)'; + } else { + postButton.style.transform = 'scale(0)'; + } + } + scrollPos = windowY; + } + + window.addEventListener('scroll', checkPosition); }, { passive: true }); } }); @@ -171,23 +187,6 @@ function top() { window.scroll({ top: 0, behavior: 'smooth' }); } -let scrollPos = 0; -const postButton = document.getElementById('postButton'); - -function checkPosition() { - let windowY = window.scrollY; - if (postButton != null) { - if (windowY < scrollPos) { - postButton.style.transform = 'scale(1)'; - } else { - postButton.style.transform = 'scale(0)'; - } - } - scrollPos = windowY; -} - -window.addEventListener('scroll', checkPosition); - const wallpaper = localStorage.getItem('wallpaper') != null;