Skip to content

Commit 0a4650d

Browse files
committed
logo colour interaction change for mobile
1 parent bbd9fde commit 0a4650d

2 files changed

Lines changed: 45 additions & 2 deletions

File tree

lets-encode-logo.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,24 @@
110110
// orange -> blue -> green sequence, rather than any one hand.
111111
svg.addEventListener("touchstart", function () { playCombo(); }, { passive: true });
112112

113+
// On touch, a tap leaves :hover "stuck" on the brand, so the navbar logo
114+
// stays colourful indefinitely. Track whether the current brand interaction
115+
// is touch (and clear the settle-to-mono override on every fresh press so
116+
// hover/tap can re-colour it).
117+
var brand = document.querySelector(".brand");
118+
var brandTouched = false;
119+
if (brand) {
120+
brand.addEventListener("pointerdown", function (e) {
121+
brand.classList.remove("is-mono");
122+
brandTouched = (e.pointerType === "touch");
123+
});
124+
// Fallback for browsers that fire touchstart without pointer events.
125+
brand.addEventListener("touchstart", function () {
126+
brand.classList.remove("is-mono");
127+
brandTouched = true;
128+
}, { passive: true });
129+
}
130+
113131
// "Back to top" links (navbar brand, footer wordmark) replay the full combo
114132
// once the scroll-to-top has settled. The target is the document top, so we
115133
// just wait for scrollY to reach 0 — covers smooth scrolling, instant jumps,
@@ -119,8 +137,17 @@
119137
link.addEventListener("click", function () {
120138
var tries = 0;
121139
var iv = window.setInterval(function () {
122-
if (window.scrollY < 1) { window.clearInterval(iv); playCombo(); }
123-
else if (++tries > 60) { window.clearInterval(iv); }
140+
if (window.scrollY < 1) {
141+
window.clearInterval(iv);
142+
// Touch only: settle the navbar logo back to monochrome as soon as
143+
// the scroll-to-top completes (the class outranks the stuck :hover).
144+
// Skipped on mouse/pen, where :hover correctly keeps colour while
145+
// hovering. Done before playing so the hero gets the colour, not it.
146+
if (brandTouched && link.closest(".brand")) {
147+
brand.classList.add("is-mono");
148+
}
149+
playCombo();
150+
} else if (++tries > 60) { window.clearInterval(iv); }
124151
}, 40);
125152
});
126153
});

styles.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,22 @@ a:hover {
164164
opacity: 1;
165165
}
166166

167+
/* Settle back to monochrome after a touch tap (JS adds .is-mono once the hero
168+
combo has played). Touch leaves :hover stuck "on", so these must outrank the
169+
:hover rules above — same specificity, so they rely on coming later in source.
170+
Also drops the hover lift so the logo returns to rest. */
171+
.brand.is-mono .brand-logo-rest {
172+
opacity: 1;
173+
}
174+
175+
.brand.is-mono .brand-logo-hover {
176+
opacity: 0;
177+
}
178+
179+
.brand.is-mono .brand-logo {
180+
transform: none;
181+
}
182+
167183
/* Plaintext wordmark — shown only on mobile (see the max-width: 560px block),
168184
where it replaces the logo image. Hidden by default on wider screens. */
169185
.brand-text {

0 commit comments

Comments
 (0)