|
110 | 110 | // orange -> blue -> green sequence, rather than any one hand. |
111 | 111 | svg.addEventListener("touchstart", function () { playCombo(); }, { passive: true }); |
112 | 112 |
|
| 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 | + |
113 | 131 | // "Back to top" links (navbar brand, footer wordmark) replay the full combo |
114 | 132 | // once the scroll-to-top has settled. The target is the document top, so we |
115 | 133 | // just wait for scrollY to reach 0 — covers smooth scrolling, instant jumps, |
|
119 | 137 | link.addEventListener("click", function () { |
120 | 138 | var tries = 0; |
121 | 139 | 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); } |
124 | 151 | }, 40); |
125 | 152 | }); |
126 | 153 | }); |
|
0 commit comments