diff --git a/src/components/Topbar/Topbar.vue b/src/components/Topbar/Topbar.vue index 8474cc31..abde1865 100644 --- a/src/components/Topbar/Topbar.vue +++ b/src/components/Topbar/Topbar.vue @@ -53,15 +53,21 @@ const avatarShadow = ref() as Ref const favoritesPopRef = ref() const scrollTop = ref(0) -const preventShowTopbar = ref(false) +const preventAdjustTopbarVisible = ref(false) watch(scrollTop, (newVal, oldVal) => { - if (newVal === oldVal) + if (newVal === oldVal) { + preventAdjustTopbarVisible.value = true return - if (newVal <= 0 || Math.abs(newVal - oldVal) < 5) - preventShowTopbar.value = true + } + // Set a certain offset in pixels to prevent minor scrolling from triggering adjustments + // in the top bar visibility + const offset = 5 + + if (newVal <= 0 || Math.abs(newVal - oldVal) < offset) + preventAdjustTopbarVisible.value = true else - preventShowTopbar.value = false + preventAdjustTopbarVisible.value = false }) watch( @@ -98,13 +104,13 @@ watch(showFavoritesPop, (newVal, oldVal) => { }) watch(activatedPage, () => { - hideTopbar.value = false - emitter.emit('topbarVisibleChange', true) + toggleTopbarVisible(true) }) -onMounted(() => { +onMounted(async () => { initData() - + await nextTick() + toggleTopbarVisible(true) window.addEventListener('wheel', handleWheelScroll) window.addEventListener('scroll', handleScroll) }) @@ -136,7 +142,7 @@ function handleWheelScroll(event: WheelEvent): void { scrollTop.value = document.documentElement.scrollTop } - if (preventShowTopbar.value) + if (preventAdjustTopbarVisible.value) return toggleTopbarVisible(true) diff --git a/src/contentScripts/views/App.vue b/src/contentScripts/views/App.vue index 2e34d22b..02eaba00 100644 --- a/src/contentScripts/views/App.vue +++ b/src/contentScripts/views/App.vue @@ -252,12 +252,12 @@ provide('scrollbarRef', scrollbarRef)
-
+
diff --git a/src/contentScripts/views/Home/Home.vue b/src/contentScripts/views/Home/Home.vue index db7f8046..95ac92a1 100644 --- a/src/contentScripts/views/Home/Home.vue +++ b/src/contentScripts/views/Home/Home.vue @@ -134,7 +134,7 @@ onUnmounted(() => {
    @@ -184,7 +184,7 @@ onUnmounted(() => { } .hide { - transform: translateY(-70px); + --at-apply: important-translate-y--70px; } .tab-activated { diff --git a/src/contentScripts/views/Home/components/Ranking.vue b/src/contentScripts/views/Home/components/Ranking.vue index 0c08a401..90672f24 100644 --- a/src/contentScripts/views/Home/components/Ranking.vue +++ b/src/contentScripts/views/Home/components/Ranking.vue @@ -2,6 +2,7 @@ import { useI18n } from 'vue-i18n' import type { PgcModel, RankingType, RankingVideoModel } from '../types' import { settings } from '~/logic' +import emitter from '~/utils/mitt' const { t } = useI18n() @@ -41,6 +42,7 @@ const isLoading = ref(false) const activatedRankingType = ref({ ...rankingTypes.value[0] }) const videoList = reactive([]) const PgcList = reactive([]) +const shouldMoveAsideUp = ref(false) watch(() => activatedRankingType.value.id, () => { handleBackToTop(settings.value.useSearchPageModeOnHomePage ? 510 : 0) @@ -52,9 +54,28 @@ watch(() => activatedRankingType.value.id, () => { }) onMounted(() => { + emitter.on('topbarVisibleChange', (val) => { + shouldMoveAsideUp.value = false + + // Allow moving tabs up only when the top bar is not hidden & is set to auto-hide + // This feature is primarily designed to compatible with the Bilibili Evolved's top bar + // Even when the BewlyBewly top bar is hidden, the Bilibili Evolved top bar still exists, so not moving up + if (settings.value.autoHideTopbar && settings.value.isShowTopbar) { + if (val) + shouldMoveAsideUp.value = false + + else + shouldMoveAsideUp.value = true + } + }) + getRankingVideos() }) +onBeforeUnmount(() => { + emitter.off('topbarVisibleChange') +}) + function getRankingVideos() { videoList.length = 0 isLoading.value = true @@ -86,7 +107,8 @@ function getRankingPgc() {