package.cjs.react-utils.useIsElementVisibleInDom.useIsElementVisibleInDom.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neeto-commons-frontend Show documentation
Show all versions of neeto-commons-frontend Show documentation
A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.
{"version":3,"file":"useIsElementVisibleInDom.js","names":["_react","require","_useForceUpdate","_interopRequireDefault","useIsElementVisibleInDom","target","options","arguments","length","undefined","_useState","useState","_useState2","_slicedToArray2","isIntersecting","setIsIntersecting","forceUpdate","useForceUpdate","useEffect","observer","IntersectionObserver","_ref","_ref2","entry","observe","unobserve","_default","exports"],"sources":["../../../../src/react-utils/useIsElementVisibleInDom/useIsElementVisibleInDom.js"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport useForceUpdate from \"./useForceUpdate\";\n\nconst useIsElementVisibleInDom = (target, options = undefined) => {\n const [isIntersecting, setIsIntersecting] = useState(false);\n const forceUpdate = useForceUpdate();\n\n useEffect(() => {\n if (!target) return forceUpdate();\n\n const observer = new IntersectionObserver(\n ([entry]) => setIsIntersecting(entry.isIntersecting),\n options\n );\n observer.observe(target);\n\n return () => observer.unobserve(target);\n }, [target, options]);\n\n return isIntersecting;\n};\n\nexport default useIsElementVisibleInDom;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAMG,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAAIC,MAAM,EAA0B;EAAA,IAAxBC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGE,SAAS;EAC3D,IAAAC,SAAA,GAA4C,IAAAC,eAAQ,EAAC,KAAK,CAAC;IAAAC,UAAA,OAAAC,eAAA,aAAAH,SAAA;IAApDI,cAAc,GAAAF,UAAA;IAAEG,iBAAiB,GAAAH,UAAA;EACxC,IAAMI,WAAW,GAAG,IAAAC,0BAAc,EAAC,CAAC;EAEpC,IAAAC,gBAAS,EAAC,YAAM;IACd,IAAI,CAACb,MAAM,EAAE,OAAOW,WAAW,CAAC,CAAC;IAEjC,IAAMG,QAAQ,GAAG,IAAIC,oBAAoB,CACvC,UAAAC,IAAA;MAAA,IAAAC,KAAA,OAAAT,eAAA,aAAAQ,IAAA;QAAEE,KAAK,GAAAD,KAAA;MAAA,OAAMP,iBAAiB,CAACQ,KAAK,CAACT,cAAc,CAAC;IAAA,GACpDR,OACF,CAAC;IACDa,QAAQ,CAACK,OAAO,CAACnB,MAAM,CAAC;IAExB,OAAO;MAAA,OAAMc,QAAQ,CAACM,SAAS,CAACpB,MAAM,CAAC;IAAA;EACzC,CAAC,EAAE,CAACA,MAAM,EAAEC,OAAO,CAAC,CAAC;EAErB,OAAOQ,cAAc;AACvB,CAAC;AAAC,IAAAY,QAAA,GAAAC,OAAA,cAEavB,wBAAwB","ignoreList":[]}