WIP PWA for Grain
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add scroll position tracking to timeline

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+13 -1
+13 -1
src/components/pages/grain-timeline.js
··· 20 20 _commentSheetOpen: { state: true }, 21 21 _commentGalleryUri: { state: true }, 22 22 _focusPhotoUri: { state: true }, 23 - _focusPhotoUrl: { state: true } 23 + _focusPhotoUrl: { state: true }, 24 + _showScrollTop: { state: true } 24 25 }; 25 26 26 27 static styles = css` ··· 44 45 45 46 #observer = null; 46 47 #initialized = false; 48 + #boundHandleScroll = null; 47 49 48 50 constructor() { 49 51 super(); ··· 57 59 this._commentGalleryUri = ''; 58 60 this._focusPhotoUri = null; 59 61 this._focusPhotoUrl = null; 62 + this._showScrollTop = false; 60 63 61 64 // Check cache synchronously to avoid flash 62 65 this.#initFromCache(); ··· 86 89 if (!this.#initialized) { 87 90 this.#fetchTimeline(); 88 91 } 92 + this.#boundHandleScroll = this.#handleScroll.bind(this); 93 + window.addEventListener('scroll', this.#boundHandleScroll, { passive: true }); 89 94 } 90 95 91 96 disconnectedCallback() { 92 97 super.disconnectedCallback(); 93 98 this.#observer?.disconnect(); 99 + if (this.#boundHandleScroll) { 100 + window.removeEventListener('scroll', this.#boundHandleScroll); 101 + } 94 102 } 95 103 96 104 firstUpdated() { ··· 191 199 this._commentGalleryUri = ''; 192 200 this._focusPhotoUri = null; 193 201 this._focusPhotoUrl = null; 202 + } 203 + 204 + #handleScroll() { 205 + this._showScrollTop = window.scrollY > 150; 194 206 } 195 207 196 208 render() {