grubflip/js/landing.js
Sarah 05dd55e0b6 Add GrubFlip consumer app — feed, trades, chat, post, landing, admin login
Full vanilla HTML/CSS/JS consumer app with mobile-first responsive design.
Pages: feed (index), post meal, trades, messages inbox, chat, landing page,
and admin login skeleton. Uses Ava's design tokens throughout.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 05:44:30 +00:00

58 lines
1.8 KiB
JavaScript

/* ============================================
GrubFlip Landing Page — JS
Smooth scroll, nav background, scroll reveal
============================================ */
(function () {
'use strict';
// --- Smooth scroll for anchor links ---
document.querySelectorAll('a[href^="#"]').forEach(function (link) {
link.addEventListener('click', function (e) {
var target = document.querySelector(this.getAttribute('href'));
if (target) {
e.preventDefault();
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
});
// --- Nav background on scroll ---
var nav = document.querySelector('.nav');
if (nav) {
var onScroll = function () {
if (window.scrollY > 20) {
nav.classList.add('nav--scrolled');
} else {
nav.classList.remove('nav--scrolled');
}
};
window.addEventListener('scroll', onScroll, { passive: true });
onScroll();
}
// --- Scroll reveal (IntersectionObserver) ---
var revealTargets = document.querySelectorAll(
'.step, .feature-card, .testimonial__quote, .download__title'
);
if ('IntersectionObserver' in window && revealTargets.length) {
revealTargets.forEach(function (el) {
el.style.opacity = '0';
el.style.transform = 'translateY(24px)';
el.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
});
var observer = new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
observer.unobserve(entry.target);
}
});
}, { threshold: 0.15 });
revealTargets.forEach(function (el) { observer.observe(el); });
}
})();