{"_id":"@kaliber/use-is-intersecting","_rev":"46-149130bde0646ffc75cae3c8f67691f8","name":"@kaliber/use-is-intersecting","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@kaliber/use-is-intersecting","version":"1.0.0","keywords":["react","hooks","hook","viewport","visible"],"license":"MIT","_id":"@kaliber/use-is-intersecting@1.0.0","maintainers":[{"name":"joostkiens","email":"me@joostkiens.com"},{"name":"pkuepers","email":"pkuepers@kaliber.net"},{"name":"daveykropf","email":"davey@kaliber.net"},{"name":"eecolor","email":"eecolor@gmail.com"}],"contributors":[{"name":"Joost Kiens","email":"joost@kaliber.net"},{"url":"https://peeke.nl","name":"Peeke Kuepers","email":"peeke@kaliber.net"}],"dist":{"shasum":"27cc9fa5b16c2660ca2bc655b3f534955840a4d2","tarball":"https://registry.npmjs.org/@kaliber/use-is-intersecting/-/use-is-intersecting-1.0.0.tgz","fileCount":6,"integrity":"sha512-aUqVH7hfvHyDRDjwysOc3gM6BCoSkPKMHN5Yco2HW7vyP1oujca8NsXKdS68oc/yid0gRJ2M9K6PeKF3ru5B0g==","signatures":[{"sig":"MEUCIFCBBzTjz5aBLMhjoNUxrraJEcWrU+FBgwFOTGiFwRV0AiEA+fRE1wIWuJBpxm4cX5L58+0rkKca3I/NYTSGDwFtIHQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5152,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJekGfyCRA9TVsSAnZWagAA3X0P/3qH9jmdqTqmkAGGXJiE\nj+BfS6BdAJCOnIvZFWVymEsmtQgG6VsecetfCJWBW1JtmmdJr3chhA+fUq+s\nZSKaoyycAEMTUZKHNqXtOC/nXroGOUqf+nhvlHqtppw9oa7Ah8t+boRqGq0K\nZwvpG70azUeEE696i4CT25Y5selIsT2ESVSDrzUGIWqPYSMJG/yq9tQt/KgI\nDjA1jJt2hbxQ4ioBVwqjmssaypqgcyarCjxt9yP8s9pGYmQk2ku9o6NIGWEp\nIgaGrcbadfJGrSsy/Ug47Tic+q1O4yOE5NU6P8TorFbOijSFxDTDhzUMTv7m\n/sO08xUZFCGyhU4XlOL81ujtBB4VVc0q3HLsJhSFy2Jcj/UizPJVIYwO5HgR\nNbvnAhKlLKhaChd4E3Nc3+47W0KdslYWckOEEryMAH9HZakathOEYIduNVYM\nBoS4ibsr6ZZ1cNmG91ZsgAqFMP68L2eDyQkB8ikQ6+TFZE9JC3kdoik4x0P2\nDByQiBwtgIfL498wD5DK9VFYU93ecdjIKY5vcHBgPgLL/OkzFkq5RF9k19JF\n7dsBpHLTG/8+fJ8km+cZjFEJB31SGi6OO8V2WantWEv9u9ySqUDHccPhioUB\no31SzgUPEX0K6Nh2fSpGtOv+eeJOeSz+GoKdwIC3P3tEvxe4T8Wo42bscEfo\nHsxq\r\n=QsRX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","private":false,"_npmUser":{"name":"pkuepers","email":"pkuepers@kaliber.net"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"https://github.com/kaliberjs/use-is-intersecting.git","type":"git"},"description":"Returns whether an element intersects with a parent element, using the IntersectionObserver","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2019 kaliber.js\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","sideEffects":false,"dependencies":{"@kaliber/use-observed-ref":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/use-is-intersecting_1.0.0_1586522098120_0.09180034560615447","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@kaliber/use-is-intersecting","version":"1.0.1","keywords":["react","hooks","hook","viewport","visible"],"license":"MIT","_id":"@kaliber/use-is-intersecting@1.0.1","maintainers":[{"name":"daveykropf","email":"davey@kaliber.net"},{"name":"eecolor","email":"eecolor@gmail.com"},{"name":"joostkiens","email":"me@joostkiens.com"},{"name":"pkuepers","email":"pkuepers@kaliber.net"}],"contributors":[{"name":"Joost Kiens","email":"joost@kaliber.net"},{"url":"https://peeke.nl","name":"Peeke Kuepers","email":"peeke@kaliber.net"}],"dist":{"shasum":"bb1e9de7a1838404c4d1fd3610525aa2768c007e","tarball":"https://registry.npmjs.org/@kaliber/use-is-intersecting/-/use-is-intersecting-1.0.1.tgz","fileCount":6,"integrity":"sha512-IGOxBsMal52J8EKDnQUeNSfhgY/CXCr6+VfhkPFUNAOeS9k/mkmJfe/qJlaGJhiId0hpeEEi98v4n1fwzOpdNA==","signatures":[{"sig":"MEUCIQDMkHL4kQB04DmY7lM836rZW+eMe4jnYhjmoNuAxK+uoAIgHQa6UJe3BjJsvhcyt0n74B2YH49Syv27yoGtYb0GYhg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5193,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe52HRCRA9TVsSAnZWagAAbbYP/RDZ2+n8ydWfTayLBID8\n0J8s49kDIR16RMeDSt7WN6zu6p5h1/gQRe2UeRB5futcgjQaDtOOAbZYwp+M\nd12XYRdL+M6ufWsUCpIJ97PaxrSJtVUoRbqYB4vqf26Las6iwVvCTmdDcwqD\nh3TsdyE78n9BMiWuXy7qV2KBmj2j3jcNnWDK+NZQX+qECaQuY5OHrQZsBoBp\nbzaQZCsNv8WoHTkyecj/P9EKyLTZh/fdewZFUrLjQ9bNkfngF+GMAPbE4fYU\nkfc4H6fyOOo62zXyvGsze8lB043uAvnDJd60vYFvTdRgsm2sYHt6J8cHvvhi\nDgQfp74OTUKguUEKbhQeJpIqM0BKyQQ1Eb/cUbLnIZJ6MYB4FlPKdHecZ4oy\nxipQ81Pxrc3isWU0/R36OxE4Yjyx1fyFCtmcQ0M1t22j4cKKq2X3q35tj0Wv\nzZOPjYl85bGniIJ3gQTOeOAlLq1UmfnShlwWiCIAp3Zv6Vcbs+mfJy5t6UWE\nV6krh/fDwvwzD8GL8Qs1NgFEjbD9ZkapUXH97aoucTl2wRMAnd2FIyaWPXqz\nUA7y1PZ8obb1/1fQHrKU6MnOJEJPmuSvDNim08ko5OrUSOTrC5KEjhOEf0km\nGVeAJ/M/AaAa+/G+F1x3JbSon1V3NmLK23itlCoHw3OkiQgahHhIpyf9oiYR\nA0li\r\n=F/To\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","private":false,"_npmUser":{"name":"pkuepers","email":"pkuepers@kaliber.net"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"https://github.com/kaliberjs/use-is-intersecting.git","type":"git"},"description":"Returns whether an element intersects with a parent element, using the IntersectionObserver","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2019 kaliber.js\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","sideEffects":false,"dependencies":{"@kaliber/use-observed-ref":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/use-is-intersecting_1.0.1_1592222161073_0.6338002750850718","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@kaliber/use-is-intersecting","version":"1.1.0","keywords":["react","hooks","hook","viewport","visible"],"license":"MIT","_id":"@kaliber/use-is-intersecting@1.1.0","maintainers":[{"name":"daveykropf","email":"davey@kaliber.net"},{"name":"eecolor","email":"eecolor@gmail.com"},{"name":"joostkiens","email":"me@joostkiens.com"},{"name":"pkuepers","email":"pkuepers@kaliber.net"}],"contributors":[{"name":"Joost Kiens","email":"joost@kaliber.net"},{"url":"https://peeke.nl","name":"Peeke Kuepers","email":"peeke@kaliber.net"}],"dist":{"shasum":"b9d1b8be74125dfae5e6aba0cffd76a834214e34","tarball":"https://registry.npmjs.org/@kaliber/use-is-intersecting/-/use-is-intersecting-1.1.0.tgz","fileCount":6,"integrity":"sha512-I2bA+NSID6JEFpcoVVJdOSOTa99rkbujnpuDBwOgwDQJH56SonHZE5OvQwoxdleY5aJSBJzcUGe/PhuPlWlI3w==","signatures":[{"sig":"MEUCIQDfdo3dHu9TkR4J660iaZ8nWZLoy4l4XZo6RrUMVtYqJQIgc6yHZaNEwXOyRV7vYP3nJZzl21eeuInP3JyKJTnofzI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6394,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNi4cCRA9TVsSAnZWagAAevMP/0mC41DM5oI8doNK6PGZ\nJ8iZaQkxVsJ3gTY86xmysw5rXaJ6MBm1FNXj+k85OJ6pSOCorI1E6SrdZeHW\n9h74cxExgRkhHOLdOllfU0xz+XtTw3Rl+tQpnPmFaH0DZ2Rv6tedTEiMaOg7\nv34w8GQQ4yHw884Ju2o6XIKiAe18hpJowacm8Jza782pjwyRtgMsjzINWu8c\nPkU+KH9vOBl0xsoIh28d6FwWSvgALy747ZNxSqAFdaVa/noOFJCW/8Jd+lLu\nbOTfQa8lBjy2eA/MQMgC7V1yRyD/nugFIYqJVgHDIw8vCSKCmzfzDlXvA/bO\nwJTz73MunbViayxfH54vhpkLtc/3+oOOQdgDAi5+cjnZP6b3QRqthce5Ud1L\n2Fk0eo1lpyh9VQzgvHGYvfd7E8BHO0ypPXv1LRPNBAaR/gr+iPgDbPOMHX3q\nZAhyNDmTl9WpaldvdI1Xu74EMk0U4MmzjX3wTUMbR9s9A5FAx4wrSlDVMDjR\nyjXYHz8w10J9Tydr4s3NF5hNMbcRDhE1nll+qGx6q1ZcA0hKOB7AEdIjlzcl\nE370wyFHGtXrKh0IQ4pgD/t+IpHSrqnInPgEAJzNwNPntVTcUUuKpWKsl6m4\nJNgbXvq8ydqwsdi3rUk6LfyTFYSmZawjEHIuJ2shpziuIbg6eC8WZterrJSW\n/pb/\r\n=+k5u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","private":false,"_npmUser":{"name":"pkuepers","email":"pkuepers@kaliber.net"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"https://github.com/kaliberjs/use-is-intersecting.git","type":"git"},"description":"Returns whether an element intersects with a parent element, using the IntersectionObserver","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2019 kaliber.js\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","sideEffects":false,"dependencies":{"@kaliber/use-observed-ref":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/use-is-intersecting_1.1.0_1597386268312_0.7455870848744659","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-04-10T12:34:57.887Z","modified":"2026-09-09T12:43:44.199Z","1.0.0":"2020-04-10T12:34:58.347Z","1.0.1":"2020-06-15T11:56:01.197Z","1.1.0":"2020-08-14T06:24:28.450Z"},"license":"MIT","keywords":["react","hooks","hook","viewport","visible"],"repository":{"url":"https://github.com/kaliberjs/use-is-intersecting.git","type":"git"},"description":"Returns whether an element intersects with a parent element, using the IntersectionObserver","contributors":[{"name":"Joost Kiens","email":"joost@kaliber.net"},{"url":"https://peeke.nl","name":"Peeke Kuepers","email":"peeke@kaliber.net"}],"maintainers":[{"email":"davey@kaliber.net","name":"daveykropf"},{"email":"ewestra@kaliber.net","name":"eecolor"},{"email":"jduijm@kaliber.net","name":"jerryduijm"},{"email":"development@kaliber.net","name":"kaliber-owner"},{"email":"nhoenderop@kaliber.net","name":"nhoenderop"},{"email":"jbrunemann@kaliber.net","name":"janbru"},{"email":"asmit@kaliber.net","name":"albertkaliber"},{"email":"mvanbrakel@kaliber.net","name":"mvanbrakel"},{"email":"Rvanschaik@kaliber.net","name":"r0h-oh"},{"email":"claan@kaliber.net","name":"1cln"},{"email":"mreimus@kaliber.net","name":"maart-22"},{"email":"ldavidsondescelles@kaliber.net","name":"yoreljenkins"},{"email":"mdevalk@kaliber.net","name":"mdevalk1983"},{"email":"guido.evertzen@gmail.com","name":"guido.evertzen"},{"email":"svroom@kaliber.net","name":"svroom-kaliber"},{"email":"tomharms93@proton.me","name":"tomharms"},{"email":"rinus.vh@hotmail.com","name":"rinus.vh"},{"email":"pgoddijn@gmail.com","name":"pgoddijn"},{"email":"jvankralingen@kaliber.net","name":"jvankralingen"}],"readme":"# useIsIntersecting\nCheck whether an element intersects with its root element\n\n## Motivation\nReports wether an element is intersecting a root element using the [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API). This is more performant and easier to use than listening to `scroll` and `resize` events and even responds to element resizing, which might not trigger these events. \n\n## Polyfill\nThe `IntersectionObserver` is [supported by most current browsers](https://caniuse.com/#search=intersectionobserver). If you need wider support, there is a [polyfill](https://www.npmjs.com/package/intersection-observer) available through polyfill.io.\n\nUsing @kaliberjs/build, you can add the following argument to the `polyfill()` call.\n```\n{polyfill(['default', 'IntersectionObserver'])}\n```\n\nWithout, you can manually add the following script to your page (or include it in your build):\n```\nhttps://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver\n```\n\n## Installation\n\n```\nyarn add @kaliber/use-is-intersecting\n```\n\n## Usage\n```jsx\nexport default function App() {\n  const [root, setRoot] = React.useState(null)\n  const { ref: isIntersectingRef, isIntersecting } = useIsIntersecting({ root, rootMargin: '-10%' })\n  const { ref: wasIntersectingRef, wasIntersecting } = useWasIntersecting({ root, rootMargin: '-10%' })\n\n  return (\n    <div>\n      <div className={styles.scrollWrapper}>\n        <div ref={setRoot} className={styles.scroll}>\n          <div ref={isIntersectingRef}>\n            {isIntersecting \n              ? 'Is in intersection root element'  \n              : 'Is not in intersection root element'}\n          </div>\n\n          <div ref={wasIntersectingRef} >\n            {wasIntersecting \n              ? 'Has been in intersection root element' \n              : 'Has not yet been in intersection root element'}\n          </div>\n        </div>\n      </div>\n    </div>\n  )\n}\n```\n\nThe `useIsIntersecting` hook also returns wether an element has been intersecting in the past (`wasIntersecting`). The main difference with the dedicated `useWasIntersecting` hook is that the IntersectionObserver doesn't get cleaned up, since the hook still has to track wether the element is currently intersecting. This can be useful if you want to pause an expensive operation, but also want the element to have a reveal animation.\n\n```jsx\nexport default function App() {\n  const [root, setRoot] = React.useState(null)\n  const { ref: elementRef, isIntersecting, wasIntersecting } = useIsIntersecting({ root })\n\n  return (\n    <div>\n      <div className={styles.scrollWrapper}>\n        <div ref={setRoot} className={styles.scroll}>\n          <div ref={elementRef} className={cx(wasIntersecting && styles.isRevealed)}>\n            {isIntersecting \n              ? 'Is in intersection root element'  \n              : 'Is not in intersection root element'}\n          </div>\n        </div>\n      </div>\n    </div>\n  )\n}\n```\n\n![](https://media.giphy.com/media/H9TLJHctw7Efm/giphy.gif)\n\n## Disclaimer\nThis library is intended for internal use, we provide __no__ support, use at your own risk. It does not import React, but expects it to be provided, which [@kaliber/build](https://kaliberjs.github.io/build/) can handle for you.\n\nThis library is not transpiled.\n","readmeFilename":"readme.md"}