All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.cjs.react-utils.useIsElementVisibleInDom.useIsElementVisibleInDom.js.map Maven / Gradle / Ivy

Go to download

A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.

There is a newer version: 4.12.3
Show newest version
{"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,GAAE;EAEpC,IAAAC,gBAAS,EAAC,YAAM;IACd,IAAI,CAACb,MAAM,EAAE,OAAOW,WAAW,EAAE;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,OAAO,CACR;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,GAEatB,wBAAwB;AAAAuB,OAAA,cAAAD,QAAA"}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy