From 1cb791b4a5ddc7237a0299a99f8d2bef5cbf9e44 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Wed, 24 May 2023 22:25:20 -0700 Subject: [PATCH] top-matter: hide shadow when dynamic visible Signed-off-by: Varun Patil --- src/components/ScrollerManager.vue | 7 +- .../top-matter/PublicShareHeader.ts | 7 +- src/components/top-matter/TopMatter.vue | 65 +++++++++++-------- 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/components/ScrollerManager.vue b/src/components/ScrollerManager.vue index a1adb5f0..1606c081 100644 --- a/src/components/ScrollerManager.vue +++ b/src/components/ScrollerManager.vue @@ -96,6 +96,8 @@ export default defineComponent({ lastAdjustHeight: 0, /** Height of the entire photo view */ recyclerHeight: 100, + /** Height of the dynamic top matter */ + dynTopMatterHeight: 0, /** Space to leave at the top (for the hover cursor) */ topPadding: 0, /** Rect of scroller */ @@ -209,6 +211,7 @@ export default defineComponent({ emit('memories.recycler.scroll', { current: scroll, previous: this.lastKnownRecyclerScroll, + dynTopMatterVisible: scroll < this.dynTopMatterHeight, }); this.lastKnownRecyclerScroll = scroll; @@ -311,7 +314,7 @@ export default defineComponent({ adjustNow() { // Refresh height of recycler this.recyclerHeight = this.recycler?.$refs.wrapper.clientHeight ?? 0; - const extraY = this.recyclerBefore?.clientHeight ?? 0; + this.dynTopMatterHeight = this.recyclerBefore?.clientHeight ?? 0; // Exclude hover cursor height const hoverCursor = this.$refs.hoverCursor; @@ -326,7 +329,7 @@ export default defineComponent({ // y position. When you hit a row with the tick, update y and // top values and move to the next tick. let tickId = 0; - let y = extraY; + let y = this.dynTopMatterHeight; let count = 0; // We only need to recompute top and visible ticks if count diff --git a/src/components/top-matter/PublicShareHeader.ts b/src/components/top-matter/PublicShareHeader.ts index 4cade9bb..4fa1ef78 100644 --- a/src/components/top-matter/PublicShareHeader.ts +++ b/src/components/top-matter/PublicShareHeader.ts @@ -10,9 +10,8 @@ if (title) { 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)); + subscribe('memories.recycler.scroll', ({ dynTopMatterVisible }: { dynTopMatterVisible: boolean }) => { + if (dynTopMatterVisible === isHidden) return; + header.classList.toggle('hidden', (isHidden = dynTopMatterVisible)); }); } diff --git a/src/components/top-matter/TopMatter.vue b/src/components/top-matter/TopMatter.vue index fe5c327f..d7d899a3 100644 --- a/src/components/top-matter/TopMatter.vue +++ b/src/components/top-matter/TopMatter.vue @@ -1,5 +1,11 @@ @@ -7,6 +13,8 @@