Both methods work, but neither achieves a transparent header at the top + glass only on scroll.
Question:
What’s the best way in Dawn to detect when the page is at the very top vs scrolled, and apply glassmorphism only while scrolling?
Is this doable with CSS only, or does it require a small JavaScript solution?
Scrolled down and back up – header shown again: <div class="shopify-section shopify-section-group-header-group section-header scrolled-past-header shopify-section-header-sticky animate">
So you can easily base your CSS on these classes – scrolled-past-header and shopify-section-header-sticky. Maybe shopify-section-header-hidden for transitions.
Thanks for the explanation I tried following it, but I’m honestly not 100% sure I’m applying it correctly. The header is still showing a white background at the very top, so I think I’m misunderstanding which element or class should be styled.
Would you mind explaining a bit more step by step, specifically which element in Dawn should be transparent at the top and which one should receive the glass effect on scroll?
I’d really appreciate the clarification, thanks again
It just requires a bit of JavaScript. Use scrollY to detect and add header classes for top and scrolled states. Have transparent styles by default, glass styles when scrollY is greater than zero, and reset when scrollY returns to zero. You can’t reliably determine the scroll position between pages with CSS alone in Dawn.