/* ============================================================ INDIC LEAGUE NEWS — Deep Dive Sheet (bottom sheet) Pull-down-to-close at scrollTop=0, backdrop tap, Esc. ============================================================ */ function Sheet({ open, article, onClose }) { const sheetRef = React.useRef(null); const scrollRef = React.useRef(null); const dragRef = React.useRef({ startY: 0, dragging: false, offset: 0 }); // Escape to close React.useEffect(() => { if (!open) return; const onKey = (e) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', onKey); return () => window.removeEventListener('keydown', onKey); }, [open, onClose]); // Reset scroll on open React.useEffect(() => { if (open && scrollRef.current) scrollRef.current.scrollTop = 0; }, [open, article && article.id]); // Pull-down-to-close const onPointerDown = (e) => { if (!scrollRef.current) return; if (scrollRef.current.scrollTop > 0) return; dragRef.current = { startY: e.clientY, dragging: true, offset: 0 }; e.currentTarget.setPointerCapture(e.pointerId); }; const onPointerMove = (e) => { if (!dragRef.current.dragging) return; const dy = e.clientY - dragRef.current.startY; if (dy > 0 && sheetRef.current) { dragRef.current.offset = dy; sheetRef.current.style.transform = `translateY(${dy}px)`; sheetRef.current.style.transition = 'none'; } }; const onPointerUp = () => { if (!dragRef.current.dragging) return; const dy = dragRef.current.offset; if (sheetRef.current) { sheetRef.current.style.transition = ''; sheetRef.current.style.transform = ''; } dragRef.current.dragging = false; if (dy > 110) { window.IL_Sounds && window.IL_Sounds.tap(); onClose(); } }; if (!article) return null; return ( <>
> ); } Object.assign(window, { Sheet });