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

package.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":["useEffect","useState","useForceUpdate","useIsElementVisibleInDom","target","options","arguments","length","undefined","_useState","_useState2","_slicedToArray","isIntersecting","setIsIntersecting","forceUpdate","observer","IntersectionObserver","_ref","_ref2","entry","observe","unobserve"],"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,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,OAAOC,cAAc;AAErB,IAAMC,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,GAA4CR,QAAQ,CAAC,KAAK,CAAC;IAAAS,UAAA,GAAAC,cAAA,CAAAF,SAAA;IAApDG,cAAc,GAAAF,UAAA;IAAEG,iBAAiB,GAAAH,UAAA;EACxC,IAAMI,WAAW,GAAGZ,cAAc,CAAC,CAAC;EAEpCF,SAAS,CAAC,YAAM;IACd,IAAI,CAACI,MAAM,EAAE,OAAOU,WAAW,CAAC,CAAC;IAEjC,IAAMC,QAAQ,GAAG,IAAIC,oBAAoB,CACvC,UAAAC,IAAA;MAAA,IAAAC,KAAA,GAAAP,cAAA,CAAAM,IAAA;QAAEE,KAAK,GAAAD,KAAA;MAAA,OAAML,iBAAiB,CAACM,KAAK,CAACP,cAAc,CAAC;IAAA,GACpDP,OACF,CAAC;IACDU,QAAQ,CAACK,OAAO,CAAChB,MAAM,CAAC;IAExB,OAAO;MAAA,OAAMW,QAAQ,CAACM,SAAS,CAACjB,MAAM,CAAC;IAAA;EACzC,CAAC,EAAE,CAACA,MAAM,EAAEC,OAAO,CAAC,CAAC;EAErB,OAAOO,cAAc;AACvB,CAAC;AAED,eAAeT,wBAAwB","ignoreList":[]}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy