From 93cdf4313eab40c8a41bdd5afde2e9107a886d44 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Thu, 18 Aug 2022 17:23:32 -0700 Subject: [PATCH] fix: :bug: fix scroll --- package.json | 2 +- packages/client/src/ui/universal.vue | 48 +++++++++++++++++----------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index f925ce25f0..4b55046c31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "misskey", - "version": "12.118.1-calc.9", + "version": "12.118.1-calc.9.3", "codename": "aqua", "repository": { "type": "git", diff --git a/packages/client/src/ui/universal.vue b/packages/client/src/ui/universal.vue index b86088ea63..d135e552be 100644 --- a/packages/client/src/ui/universal.vue +++ b/packages/client/src/ui/universal.vue @@ -116,22 +116,6 @@ mainRouter.on('change', () => { document.documentElement.style.overflowY = 'scroll'; -let timer = -1; -const postButton = document.getElementById('postButton'); -window.addEventListener('scroll', () => { - if (timer !== -1) { - if (postButton != null) { - postButton.style.transform = 'scale(0)'; - } - clearTimeout(timer); - } - timer = setTimeout(() => { - if (postButton != null) { - postButton.style.transform = 'scale(1)'; - } - }, 150); -}, false); - if (defaultStore.state.widgets.length === 0) { defaultStore.set('widgets', [{ name: 'calendar', @@ -153,7 +137,7 @@ onMounted(() => { } }); -const onContextmenu = (ev) => { +const onContextmenu = (ev: MouseEvent) => { const isLink = (el: HTMLElement) => { if (el.tagName === 'A') return true; if (el.parentElement) { @@ -176,7 +160,7 @@ const onContextmenu = (ev) => { }], ev); }; -const attachSticky = (el) => { +const attachSticky = (el: any) => { const sticky = new StickySidebar(widgetsEl); window.addEventListener('scroll', () => { sticky.calc(window.scrollY); @@ -187,8 +171,26 @@ function top() { window.scroll({ top: 0, behavior: 'smooth' }); } +let scrollPos = 0; +const postButton = document.querySelector('.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; +