fix(site): restore CSS lost in 6c14e64; gallery click-and-drag; no link underline + colour/glow hover; brand-colour CrossFit pill; lighter trial link; no gloss on team photos
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6c14e644b1
commit
3d2a696162
3 files changed
+871
-69
No files matched your search
@@ -787,3 +787,79 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
}
|
||||
requestAnimationFrame(tick);
|
||||
});
|
||||
|
||||
/* ── Galeria: auto-scroll + click-and-drag ───────────────────────────────────
|
||||
The strip (.gal-wrap) is four identical copies long. It advances by itself,
|
||||
follows a mouse drag (touch uses the native swipe), pauses while you hover or
|
||||
hold it and resumes a moment after, and whenever the position leaves the two
|
||||
middle copies it jumps by exactly one copy — invisible, since every copy is the
|
||||
same. A drag longer than a few px swallows the click, so it doesn't open the
|
||||
lightbox. */
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var reduce = window.matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
document.querySelectorAll('.gal-marquee').forEach(function (strip) {
|
||||
var wrap = strip.parentElement;
|
||||
var set = strip.querySelector('.gal-set');
|
||||
if (!wrap || !set) return;
|
||||
var loop = 0, pos = null, hold = false, resumeAt = 0, dragging = false, moved = 0, startX = 0, startLeft = 0, last = 0;
|
||||
var SPEED = 40; // px per second
|
||||
|
||||
function measure() { loop = set.offsetWidth; }
|
||||
function normalise() {
|
||||
if (!loop) return;
|
||||
if (wrap.scrollLeft >= loop * 2) wrap.scrollLeft -= loop;
|
||||
else if (wrap.scrollLeft < loop) wrap.scrollLeft += loop;
|
||||
}
|
||||
function start() { measure(); wrap.scrollLeft = loop; }
|
||||
start();
|
||||
window.addEventListener('load', start);
|
||||
window.addEventListener('resize', measure, { passive: true });
|
||||
wrap.addEventListener('scroll', normalise, { passive: true });
|
||||
|
||||
wrap.addEventListener('mouseenter', function () { hold = true; });
|
||||
wrap.addEventListener('mouseleave', function () { if (!dragging) { hold = false; resumeAt = performance.now() + 600; } });
|
||||
wrap.addEventListener('focusin', function () { hold = true; });
|
||||
wrap.addEventListener('focusout', function () { hold = false; });
|
||||
wrap.addEventListener('touchstart', function () { hold = true; }, { passive: true });
|
||||
wrap.addEventListener('touchend', function () { hold = false; resumeAt = performance.now() + 1800; }, { passive: true });
|
||||
|
||||
wrap.addEventListener('pointerdown', function (e) {
|
||||
if (e.pointerType === 'touch' || e.button !== 0) return;
|
||||
dragging = true; moved = 0;
|
||||
startX = e.clientX; startLeft = wrap.scrollLeft;
|
||||
wrap.classList.add('is-dragging');
|
||||
wrap.setPointerCapture(e.pointerId);
|
||||
});
|
||||
wrap.addEventListener('pointermove', function (e) {
|
||||
if (!dragging) return;
|
||||
var dx = e.clientX - startX;
|
||||
moved = Math.max(moved, Math.abs(dx));
|
||||
wrap.scrollLeft = startLeft - dx;
|
||||
});
|
||||
function endDrag(e) {
|
||||
if (!dragging) return;
|
||||
dragging = false;
|
||||
wrap.classList.remove('is-dragging');
|
||||
try { wrap.releasePointerCapture(e.pointerId); } catch (err) {}
|
||||
resumeAt = performance.now() + 1200;
|
||||
}
|
||||
wrap.addEventListener('pointerup', endDrag);
|
||||
wrap.addEventListener('pointercancel', endDrag);
|
||||
// After a real drag, the click that follows must not open the lightbox.
|
||||
wrap.addEventListener('click', function (e) {
|
||||
if (moved > 5) { e.preventDefault(); e.stopPropagation(); moved = 0; }
|
||||
}, true);
|
||||
|
||||
function tick(now) {
|
||||
requestAnimationFrame(tick);
|
||||
var dt = last ? Math.min(now - last, 100) : 16; last = now;
|
||||
if (reduce || document.hidden || dragging || hold || now < resumeAt) { pos = null; return; }
|
||||
// scrollLeft only keeps whole pixels, so a ~0.6px/frame step would round
|
||||
// away: carry the fraction in our own float and write it back.
|
||||
if (pos === null || Math.abs(wrap.scrollLeft - pos) > 2) pos = wrap.scrollLeft;
|
||||
pos += SPEED * dt / 1000;
|
||||
wrap.scrollLeft = pos;
|
||||
}
|
||||
requestAnimationFrame(tick);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user