{"version":3,"file":"useIsOnScreen-SdhMrWfs.js","sources":["../../../app/javascript/hooks/useIsOnScreen.tsx"],"sourcesContent":["import { useState, useEffect } from \"react\";\n\nexport default function useIsOnScreen(element, rootMargin = \"0px\") {\n const [isVisible, setState] = useState(false);\n\n useEffect(() => {\n if (element?.current) {\n const observer = new IntersectionObserver(\n ([entry]) => {\n setState(entry.isIntersecting);\n },\n { rootMargin }\n );\n\n if (element.current) {\n observer.observe(element.current);\n }\n\n return () => {\n if (element?.current) {\n observer.unobserve(element.current);\n }\n };\n }\n }, [element?.current]);\n\n return isVisible;\n}\n"],"names":["useIsOnScreen","element","rootMargin","isVisible","setState","useState","useEffect","observer","entry"],"mappings":"yCAEwB,SAAAA,EAAcC,EAASC,EAAa,MAAO,CACjE,KAAM,CAACC,EAAWC,CAAQ,EAAIC,WAAS,EAAK,EAE5CC,OAAAA,EAAAA,UAAU,IAAM,CACd,GAAIL,GAAA,MAAAA,EAAS,QAAS,CACpB,MAAMM,EAAW,IAAI,qBACnB,CAAC,CAACC,CAAK,IAAM,CACXJ,EAASI,EAAM,cAAc,CAC/B,EACA,CAAE,WAAAN,CAAW,CAAA,EAGf,OAAID,EAAQ,SACDM,EAAA,QAAQN,EAAQ,OAAO,EAG3B,IAAM,CACPA,GAAA,MAAAA,EAAS,SACFM,EAAA,UAAUN,EAAQ,OAAO,CACpC,CAEJ,CAAA,EACC,CAACA,GAAA,YAAAA,EAAS,OAAO,CAAC,EAEdE,CACT"}