How do you change the wordmark / logo on scroll in the theme Dawn?
My wordmark/logo is currently white (titled wordmark-white.png in content), but I’d like it to switch to the burgundy/red version (wordmark-red.png) when you scroll down the homepage or navigate to any other page. In other words, I only want the white wordmark to appear when someone is at the very top of the homepage.
I was working in a duplicate theme, not my live one. I followed the three steps exactly as instructed, and then I added your code to theme.liquid. Nothing changed, super odd.. Maybe something is incorrect in step 1-3?
I’ve been trying everything for hours. Sometimes I get really close, but there’s always something wrong. At one point, I had it working on the homepage, but not on the other pages. Other times, it worked when scrolling down but not when scrolling back up. Another time, both wordmarks were showing on top of each other. It feels like every fix either creates a new issue somewhere else or nothing happens at all.
I tend to recommend solutions which do not require editing theme code.
Avoiding theme code edit will make your theme version updates easier.
Yes, generally, a proper way is to include two logo images in your HTML and then show either one or another on scroll. This would require theme code edit.
In this case (logo is the same, just different color) there is a way to reach your goal without theme code edits.
What you should try:
Set your logo to the red image.
This is also better for SEO/AIO – if they serve their output on white background, white logo would not show;
On your homepage, add a “Custom liquid” section at the bottom of the “Template” area.
Because it’s inside “Template” area, it will only render on the page which uses this template – meaning Homepage only;
Paste this code into “Custom liquid”:
The code will “brighten up ” logo to white if the page is not scrolled/at the top.
WOW you are the best. It worked perfectly !! THANK YOU. Is it possible to trigger the color change when the “SHOP” dropdown menu is opened/hovered also?
Hey Tim! Back again - I just noticed a vague pink outline around the logo letters on the mobile version of the homepage. Any idea where that’s coming from or how to get rid of it? Thanks so much!
I do not quite see it in my browser, but probably the image is not brightened enough.
Because the color is not completely flat and the edges are antialiased, especially after resizing (theme code does it) there will be an outline of a different tint, like in this screenshot (contrast it bumped to better illustrate):