{"version":3,"file":"intersectionObserver.mjs","names":["onBeforeUnmount","ref","shallowRef","watch","SUPPORTS_INTERSECTION","useIntersectionObserver","callback","options","intersectionRef","isIntersecting","observer","IntersectionObserver","entries","value","find","entry","disconnect","newValue","oldValue","unobserve","observe","flush"],"sources":["../../src/composables/intersectionObserver.ts"],"sourcesContent":["// Utilities\nimport { onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport { SUPPORTS_INTERSECTION } from '@/util'\n\nexport function useIntersectionObserver (callback?: IntersectionObserverCallback, options?: IntersectionObserverInit) {\n const intersectionRef = ref()\n const isIntersecting = shallowRef(false)\n\n if (SUPPORTS_INTERSECTION) {\n const observer = new IntersectionObserver((entries: IntersectionObserverEntry[]) => {\n callback?.(entries, observer)\n\n isIntersecting.value = !!entries.find(entry => entry.isIntersecting)\n }, options)\n\n onBeforeUnmount(() => {\n observer.disconnect()\n })\n\n watch(intersectionRef, (newValue, oldValue) => {\n if (oldValue) {\n observer.unobserve(oldValue)\n isIntersecting.value = false\n }\n\n if (newValue) observer.observe(newValue)\n }, {\n flush: 'post',\n })\n }\n\n return { intersectionRef, isIntersecting }\n}\n"],"mappings":"AAAA;AACA,SAASA,eAAe,EAAEC,GAAG,EAAEC,UAAU,EAAEC,KAAK,QAAQ,KAAK;AAAA,SACpDC,qBAAqB;AAE9B,OAAO,SAASC,uBAAuBA,CAAEC,QAAuC,EAAEC,OAAkC,EAAE;EACpH,MAAMC,eAAe,GAAGP,GAAG,EAAe;EAC1C,MAAMQ,cAAc,GAAGP,UAAU,CAAC,KAAK,CAAC;EAExC,IAAIE,qBAAqB,EAAE;IACzB,MAAMM,QAAQ,GAAG,IAAIC,oBAAoB,CAAEC,OAAoC,IAAK;MAClFN,QAAQ,GAAGM,OAAO,EAAEF,QAAQ,CAAC;MAE7BD,cAAc,CAACI,KAAK,GAAG,CAAC,CAACD,OAAO,CAACE,IAAI,CAACC,KAAK,IAAIA,KAAK,CAACN,cAAc,CAAC;IACtE,CAAC,EAAEF,OAAO,CAAC;IAEXP,eAAe,CAAC,MAAM;MACpBU,QAAQ,CAACM,UAAU,EAAE;IACvB,CAAC,CAAC;IAEFb,KAAK,CAACK,eAAe,EAAE,CAACS,QAAQ,EAAEC,QAAQ,KAAK;MAC7C,IAAIA,QAAQ,EAAE;QACZR,QAAQ,CAACS,SAAS,CAACD,QAAQ,CAAC;QAC5BT,cAAc,CAACI,KAAK,GAAG,KAAK;MAC9B;MAEA,IAAII,QAAQ,EAAEP,QAAQ,CAACU,OAAO,CAACH,QAAQ,CAAC;IAC1C,CAAC,EAAE;MACDI,KAAK,EAAE;IACT,CAAC,CAAC;EACJ;EAEA,OAAO;IAAEb,eAAe;IAAEC;EAAe,CAAC;AAC5C"}