// ============================================================ // SECTION HAID — Manfaat // • Sticky title on the left // • Sachet (real photo, rotated 180°) scrolls fully right → left // and exits the screen — no stop, no tear, no liquid, no shadow // • 6 benefits appear one by one on the right as sachet travels // ============================================================ function SectionHaid() { const sectionRef = React.useRef(null); const [p, setP] = React.useState(0); const [isMobile, setIsMobile] = React.useState(false); React.useEffect(() => { const mq = window.matchMedia('(max-width: 700px)'); const update = () => setIsMobile(mq.matches); update(); if (mq.addEventListener) mq.addEventListener('change', update); else mq.addListener(update); return () => { if (mq.removeEventListener) mq.removeEventListener('change', update); else mq.removeListener(update); }; }, []); React.useEffect(() => { let raf = 0; const onScroll = () => { if (!sectionRef.current) return; const rect = sectionRef.current.getBoundingClientRect(); const total = rect.height - window.innerHeight; const scrolled = -rect.top; const np = Math.max(0, Math.min(1, scrolled / Math.max(1, total))); cancelAnimationFrame(raf); raf = requestAnimationFrame(() => setP(np)); }; window.addEventListener('scroll', onScroll, { passive: true }); onScroll(); return () => { window.removeEventListener('scroll', onScroll); cancelAnimationFrame(raf); }; }, []); // Sachet starts rotated -90° (horizontal) and 2.5× larger. // • Desktop: settles upright (0°) at normal size, centered. // • Mobile : settles HORIZONTAL (stays at -90°), slightly larger (1.2×), // with a 25px-lower start that lifts 30px as it scrolls into final pose. const sachetP = Math.max(0, Math.min(1, p / 0.70)); // ease-out cubic const ease = 1 - Math.pow(1 - sachetP, 3); const sachetEndRotate = isMobile ? -90 : 0; const sachetEndScale = isMobile ? 1.2 : 1.0; const sachetRotate = -90 + ease * (sachetEndRotate - (-90)); const sachetScale = 2.5 + ease * (sachetEndScale - 2.5); // 2.5 → endScale // Mobile-only Y offset during scroll: starts +25px, ends -5px const startYOffset = isMobile ? 25 : 0; const endYOffset = isMobile ? -5 : 0; const yOffset = startYOffset + ease * (endYOffset - startYOffset); // BG color: cream → deep crimson over the first half, then locks dark const bgT = Math.min(1, p / 0.50); const lerp = (a, b, t) => a + (b - a) * t; const rc = Math.round(lerp(248, 90, bgT)); const gc = Math.round(lerp(241, 14, bgT)); const bc = Math.round(lerp(231, 18, bgT)); const bgColor = `rgb(${rc}, ${gc}, ${bc})`; const lightMode = bgT < 0.4; const BENEFITS = [ 'Membantu Melancarkan Haid', 'Membantu Mengurangi Nyeri Haid', 'Membantu Mengurangi Gangguan Haid', 'Membantu Mengurangi Keputihan', 'Membantu Memperbaiki Siklus Haid', 'Membantu Mengurangi Bau Tidak Sedap Pada Area Kewanitaan', ]; // Benefits appear progressively across the section so all 6 are visible // by the time the sachet has fully passed. const benefitP = Math.max(0, (p - 0.10) / 0.80); return (
{/* Soft red glow when bg goes dark */}
{/* STICKY title — stays visible through entire section */}
Manfaat Yojea

6 manfaat untuk
kesehatan haid
wanita Indonesia.

Diformulasikan khusus untuk kebutuhan kesehatan wanita — membantu siklus, mengurangi nyeri, dan menjaga area kewanitaan.

{/* Sachet — starts at the right edge (60% visible, rotated -90°, 2.5×) and travels to the center while rotating upright and scaling down. */}
Yojea Sachet
{/* Benefits stack — right side, appear staggered as sachet travels */}
{BENEFITS.map((text, i) => { const t = Math.max(0, Math.min(1, (benefitP - i * 0.12) * 5)); return (
0.05 ? ' show' : '')} style={{ opacity: t, transform: `translateX(${(1 - t) * 50}px)`, }} >
{String(i + 1).padStart(2, '0')}
{text}
); })}
{/* Bottom progress hint */}
Scroll
); } Object.assign(window, { SectionHaid });