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 @@