From 449595b00685aa7d6963d73db990bcba282ac606 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Wed, 24 May 2023 22:04:14 -0700 Subject: [PATCH] public-album: fix header (fix #627) Signed-off-by: Varun Patil --- src/components/top-matter/PublicShareHeader.ts | 14 ++++++++++++++ src/global.scss | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/src/components/top-matter/PublicShareHeader.ts b/src/components/top-matter/PublicShareHeader.ts index 3652365e..4cade9bb 100644 --- a/src/components/top-matter/PublicShareHeader.ts +++ b/src/components/top-matter/PublicShareHeader.ts @@ -1,4 +1,18 @@ +import { subscribe } from '@nextcloud/event-bus'; import { loadState } from '@nextcloud/initial-state'; // Shown in dynamic top matter (Timeline::viewName) export const title = loadState('memories', 'share_title', ''); + +// Set up hook to monitor recycler scroll to show/hide header +if (title) { + const header = document.querySelector('header#header .header-appname') as HTMLElement; + let isHidden = false; // cache state to avoid unnecessary DOM updates + + // Hide header when recycler is scrolled down + subscribe('memories.recycler.scroll', ({ current }: { current: number }) => { + const hidden = current < 80; + if (hidden === isHidden) return; + header.classList.toggle('hidden', (isHidden = hidden)); + }); +} diff --git a/src/global.scss b/src/global.scss index 68f983ba..75d7b416 100644 --- a/src/global.scss +++ b/src/global.scss @@ -59,6 +59,14 @@ body.has-viewer header { z-index: 0 !important; } +// Allow hiding app name (PublicShareHeader) +header#header .header-appname { + transition: opacity 0.2s ease-in-out; + &.hidden { + opacity: 0 !important; + } +} + // Hide horizontal scrollbar on mobile // For the padding removal above #app-content-vue {